开发者

AS3.0 Quit the flash player [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

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

I made a small game in Actionscript 3.0 and flash.

When 开发者_StackOverflow中文版the player wins the game or is 'game over' my player should have 2 options. Besides replay i want the player to be able to quit the game from wihin the game. So there a way to close/quit/kill the flash player with actionscript ?


Well, you have 2 options:

  • System.exit
  • fscommand("quit")

If you want to kill the flash object inside the web page, that would be possible using JavaScript, using swfobject.removeSWF. There is a sample here.


No. You cannot kill the VM with actionscript. There are some AS3 commands to pause/resume (sleep) the flash player VM but these ONLY work in debug mode, which can only be launched locally from the IDE. It may be possible to remove the item using some server side or client side HTML/JS or something but absolutely not from within the VM itself.


Well, yes, you could use Flash to call JavaScript and remove the div/span which is holding it (see fscommand and ExternalInterface), but I don't think that is your best option -- it is too prone to failure and it is too subject to its environment.

If you can, just navigate away from that page using navigateToUrl(new URLRequest(<ip>), "_self")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜