Jump to content


Tweening & Garbage Collection

Recommended Posts

Hi everyone,


In my game, i have "explosion" movieclips and when they reach at the last frame of their animation, they are being removed from the stage & from the "explosions" array. I also remove every reference(listeners etc.) to them so that garbage collection can completely erase them from the memory at some point in the future.


The thing is, i want to add them a tween with TweenMax/TweenLite and they probably end later than the animation (Since frame rate is not constant, i can't exactly pinpoint the animation's time). So when the movieclip is already removed from the stage (and prepared for GC), the tween probably still continues (it doesn't give any error). Does it affects garbage collection? Is it certain that it will be marked for garbage collection after tween ends, or do i need to do something extra?


(For this purpose, I don' t prefer to write a TweenLite:onComplete function since it can't track event.target. It is easier for me to check if the animation ends for any of the "explosion" array members in my main onEnterFrame() function.. )



Link to comment
Share on other sites

You could use a tween to run the movieclip's animation and trigger whatever method you need in the end of the tween. That way you would have control over the whole process.

Link to comment
Share on other sites

Yeah, you don't need to worry about gc - TweenLite/Max are good at releasing things whenever possible/necessary. I put a lot of time into making it as gc-friendly and intelligent as possible. Are you running into trouble or just asking about it in theory?

Link to comment
Share on other sites

Just asking theory, i didn't run into any visible trouble but i was afraid if game can slow down in the long run because of undeleted movieclips left in memory.


In short-medium run, i didn't notice a visible difference even if i never remove movieclips from the stage (probably because they're low in numbers), so i couldn't be sure if they're piling up in the memory even if i didn't recognize it visibly.



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.