1

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

I made a small game in Actionscript 3.0 and flash.

When 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 ?

Community
  • 1
  • 1
Tieme
  • 62,602
  • 20
  • 102
  • 156

3 Answers3

2

Well, you have 2 options:

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.

Jorjon
  • 5,316
  • 1
  • 41
  • 58
  • System.exit = Line 42 1120: Access of undefined property flash. fscommand("quit") = Line 42 1180: Call to a possibly undefined method fscommand. – Tieme Jun 23 '11 at 14:30
  • First you have to import it, using **import flash.system.fscommand;** Here is an [example](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/package.html#fscommand%28%29) – Jorjon Jun 23 '11 at 14:36
0

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.

0

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")

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166