Is there an AS 3.0 play and die function?
-
03-12-2019 - |
Question
Is there any function in AS 3.0 that plays a MovieClip and then does removeChild() after it has been played? I don´t want to stop() it i just want to remove the child from stage.
Solution
As a code example, suggested by Sr.Richie, here is what is required:
Inside the MC to play and remove, add this frame code:
addEventListener(Event.ENTER_FRAME, function (e:Event):void {
if(currentFrame==totalFrames) {
removeEventListener(Event.ENTER_FRAME, arguments.callee);
parent.removeChild(this);
}
}
Note I haven't tested this code, but it's the general idea.
OTHER TIPS
No, there's no built-in method to do it.
But you can let your objects extend MovieClip, and create a custom method triggered by an ENTER_FRAME event to check if the last frame is reached, and remove them from the parent then
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow