问题
yeah, I need to restart my application, my actioscript 3 code or at least remove all the content in stage to upload the beginning.
This is not movie, so playing with gotoandplays is not an option.
Thanks!
回答1:
Best practice would be for each object that carries a strong listener to also listen for the Event.REMOVED_FROM_STAGE event, and destroy all its listeners and handle the properties you wish to save.
while(numChildren) removeChildAt(0);
Called from the root (or main timeline) will remove all symbols from the current container in scope. I assume what you're calling it in is added to the display list, so
while(MovieClip(root).numChildren) MovieClip(root).removeChildAt(0);
Is appropriate code.
回答2:
First structure design.
For example: make a gameContainer the sprite variable add to stage. while the game progresses, all object add gameContainer. When the game is ended, remove the event, you do not need to remove all the objects. And calls the function that default settings you have made that.
// removeEventListener
// removeAllObjects about following
while (gameContainer.numChildren)
{
gameContainer.removeChildAt (0);
}
来源:https://stackoverflow.com/questions/14799462/how-do-i-restart-flash-application-with-actionscript-3