PDA

View Full Version : Removing a movieclip from the stage after a set amount of time (or once it's finished


Woodsy01
06-26-2009, 11:02 AM
I've got a movieclip animation which is added to the stage at the start of the .swf. Its an introduction to the game, and the user is encouraged to click on the movieclip to start the animation.



Once the animation is finished I'd like the movieclip to be removed from the stage.



How do I go about doing this? Do I need to setup some sort of event handler which listens out if the movieclip has finished then start a function once its finished to remove it from the stage? Which methods look out for movieclips finishing?



Cheers

vdLoo88
06-26-2009, 11:34 AM
Hello,

I don't know if there are methods looking out for movieclips finishing... but maybe you can try creating a Boolean variable, for instance "animationDone". Set this variable to true at the end of your movieclip animation.

Then, in an ENTER_FRAME event on your main timeline, listen for this variable...

Something like this maybe:

if (animationDone) removeChild(movieclip);

Hope this helps!
Cheers

novasatori
06-26-2009, 12:19 PM
you could use a timer, or you could import the movieclip as a SWF....i think you can detect when an externalyl loaded SWF ends its animation.

OmerHassan
06-26-2009, 02:02 PM
A more efficient way to do this would be to add these lines in the last frame of your movie clip:
parent.removeChild(this);
stop();