actionscript 3 - Removing movieclip in timeline - really gone? -


i want explosion play when object hits object. when hittestobject true, run function

function createexplosion():void { var explosion:explosion = new explosion(enemy.x, enemy.y); this.parent.addchild(explosion); } 

explosion class consists of setting input it's x , y values. in explosion movieclip have few frames of animation. ends in keyframe (i.e., action in frame) following code:

stop(); this.parent.removechild(this); 

my question is. gone now? had add stop() not error 1009. makes me suspect event timer still running around?

removing display object display list, doesn't stop animation or remove memory. removes display list. yes, need stop animation , remove event listeners might active object.

a display object never gone until garbage collected. not happen until no references object remain. if have variable called explosion references display object, need set null after removing display list :

explosion.stop();   // stop animation removechild(explosion);  // remove display list explosion = null; // remove variable reference // explosion qualifies garbage collection. 

keep in mind doesn't remove object memory, makes fair game garbage collector. can google "as3 garbage collection" more information on process.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -