AS3.0 Replay the whole movie (*SWF file)

依然范特西╮ 提交于 2019-12-20 03:50:05

问题


I made a small game in Actionscript 3.0 and flash.

When the player wins the game or is 'game over' the player should have a option to replay the game.

So my question is: Is there a way to replay the whole movie with Actionscript? I know, i could reset the timeline back to 0, and re-instantiate all the classes, movieclips, var's ect... but i was wondering if anyone knows a easier solution.


回答1:


You can remove the swfObject and add it again. Look here. This is the swfObject reference.




回答2:


Simply do this:

import flash.net.*;
//...
navigateToURL(new URLRequest(stage.loaderInfo.url), "_level0");



回答3:


Reload the page, where you've embedded the swf into, may be the easiest way.

The programmers way would be to encapsulate your whole application into a single class (extending Sprite or MovieClip) which will be attached to the stage. For restarting the game you could simply remove that instance from the stage and add a newly created onto the stage.

Or make a loader swf, that loads your game. Then if the game should be restarted, discard (unload) the instance and load it again.

Its hard to tell you what you can do, if we don't know, how your project is structured.



来源:https://stackoverflow.com/questions/6455099/as3-0-replay-the-whole-movie-swf-file

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