Jump to content
Search Community

When an object is deleted are associated tweens killed?

Popinjay test
Moderator Tag

Recommended Posts

When an object is deleted are associated tweens killed without deleting them explicitly?

 

E.g.  If I have a movieclip that is being tweened and I remove references to it and take it off the display list but don't kill the tween.

 

My question is actually a bit more general than just for GS tweens.  I am concerned about events too.  Such as if I have an enter-frame event for a MC and then remove the MC.  Is the enter frame event still taking up some process time or does it disappear with the next garbage collection?

 

Pop

Link to comment
Share on other sites

Hi,

 

When an object is deleted are associated tweens killed without deleting them explicitly?

 

 

Nope. You would have to manage the killing of tweens yourself.

 

Try this basic example:

 

 

TweenLite.to(mc, 2, {x:400, onUpdate:moveIt});


function moveIt():void{
trace(mc.x);
}


function removeIt():void{
removeChild(mc);
mc = null;
}


TweenLite.delayedCall(1, removeIt);

You will see that even after the mc is killed and null=ed by the removeIt() function, the tween is still running. 

 

This can easily be remedied with TweenLite.killTweensOf().

 

 

function removeIt():void{
TweenLite.killTweensOf(mc);
removeChild(mc);
mc = null;
}

 

 

 

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...