1
votes

can anyone tell me what is wrong with my exit button...even thought i use "fscommand" when i click exit button it doesn't close my flash game...another button is going well..

package
{
	import flash.display.*;
	import flash.events.*;
	import flash.geom.*;
	import flash.text.*;
	import flash.utils.*;
	import flash.ui.*;
	import flash.system.fscommand;


public function startMenu()
		{
			btnPlay.addEventListener(MouseEvent.CLICK, gotoGame);
			btnHelp.addEventListener(MouseEvent.CLICK, gotoHelp);
			btnExit.addEventListener(MouseEvent.CLICK, gotoExit);
		}
		
		private function gotoExit(evt:MouseEvent)
		{
			btnExit.addEventListener(MouseEvent.CLICK, gotoExit);
			fscommand("quit", "");
		}

        private function gotoHelp(evt:MouseEvent)
		{
			btnHelp.removeEventListener(MouseEvent.CLICK, gotoHelp);
			gotoAndStop("Help");
		}
		
		private function gotoGame(evt:MouseEvent)
		{
			btnPlay.removeEventListener(MouseEvent.CLICK, gotoGame);
			gotoAndStop("game");
		}
2
You publish for what? Web, AIR, other ... ? - BotMaster
for game flash? That's not a publish target at all. You have no idea where your game is gonna run? Beginner? - BotMaster
fscommand("quit"), not fscommand("quit", ""). BTW this command is pointless and may not work in browser. When user wants to quit, he can just close the window. - Andrei Nikolaenko
It will be run in flash player..i'm not publishing to AIR or web...just make it to .swf and run in flash player...so i need button exit work to close flash player...and yes i'm nubie - Irfan Syah
So what should i write to make flash player app closed when i click exit button??? - Irfan Syah

2 Answers

0
votes

According to Adobe, fscommand() and System.exit() are available only for Flash Player Standalone version (and debugger for System.exit() which is not correct).

Take this example of code :

btn_fscommand_quit.addEventListener(
    MouseEvent.CLICK,
    function(e:MouseEvent):void {
        fscommand('quit');
    }
)
btn_system_exit.addEventListener(
    MouseEvent.CLICK,
    function(e:MouseEvent):void {
        try {
            System.exit(0);
        } catch(error:Error){
            log.text = error.toString();
        }
    }
)

Which I tested and it's working fine with a release version of Flash Player 11 :

enter image description here

You can download the fla (CS6), the swf and a projection (.exe) from here.

Hope that can help.

0
votes

In your gotoExit method, you wrote :

btnExit.addEventListener(MouseEvent.CLICK, gotoExit);

instead of :

btnExit.removeEventListener(MouseEvent.CLICK, gotoExit);