Jump to content
Search Community

Loader.unloadAndStop() doesn't stop Tweenlite...

unpaidintern test
Moderator Tag

Recommended Posts

today i built a little flash modal sort of thing... when loading a swf into the modal, i use a test swf that has some objects getting tweened around using TweenLite (a continuous loop via onComplete that traces every cycle ) along with a Timer (that traces every 2 sec)... and when you close the modal, the loader's unloadAndStop method is called... the timer is killed (note: i also checked to see if an ENTER_FRAME listener would be effectively killed, and it was), but of course the TweenLite tweens keep on going...

 

so i looked around for a method that would dig into the children of an object and kill all their tweens... i didn't find anything (i may have overlooked it), so i took the basics of killTweensOf() and wrote this:

 

var movie:MovieClip = loader.getChildAt( 0 ) as MovieClip;
var masterList:Dictionary = TweenLite.masterList;
for( var key:Object in masterList )
{
var p:* = key.parent;
while( p )
{
	if( p == movie ) 
	{
		var a:Array = masterList[ key ];
		var i:int = a.length;
		var tween:TweenLite;
		while (i--) 
		{
			tween = a[ i ];
			if( !tween.gc ) 
			{
				tween.complete( true, true );
				tween.setEnabled( false, true );
			}
		}
		delete masterList[ key ];
	}
	p = p.parent;
} 
} 

 

it works, but i'm curious... is there a better way to do this?

 

thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...