AS3.0 重播整部电影(*SWF 文件)
我用 Actionscript 3.0 和 flash 制作了一个小游戏。
当玩家赢得游戏或“游戏结束”时,玩家应该可以选择重玩游戏。
所以我的问题是:有没有办法用 Actionscript 重播整部电影?我知道,我可以将时间线重置回 0,并重新实例化所有类、影片剪辑、var 等...但我想知道是否有人知道更简单的解决方案。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需这样做:
Simply do this:
您可以删除 swfObject 并再次添加。请查看此处。这是 swfObject 参考。
You can remove the swfObject and add it again. Look here. This is the swfObject reference.
重新加载已嵌入 swf 的页面可能是最简单的方法。
程序员的方法是将整个应用程序封装到一个类(扩展 Sprite 或 MovieClip)中,该类将附加到舞台上。要重新启动游戏,您只需从舞台上删除该实例并将新创建的实例添加到舞台上即可。
或者制作一个 swf 加载程序来加载您的游戏。然后,如果应该重新启动游戏,请丢弃(卸载)实例并再次加载它。
如果我们不知道您的项目是如何构建的,就很难告诉您您可以做什么。
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.