How do I restart flash application with actionscript 3

梦想的初衷 提交于 2019-12-12 05:59:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!