如何在 actionscript 3 中退出命令
how to make command exit in actionscript 3
任何人都可以告诉我我的退出按钮有什么问题...即使我认为我使用 "fscommand" 当我单击退出按钮时它不会关闭我的 flash 游戏...另一个按钮运行良好。 .
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");
}
在您的 gotoExit 方法中,您写道:
btnExit.addEventListener(MouseEvent.CLICK, gotoExit);
而不是:
btnExit.removeEventListener(MouseEvent.CLICK, gotoExit);
根据 Adobe 的说法,fscommand()
and System.exit()
仅适用于 Flash Player Standalone 版本(System.exit()
的调试器不正确)。
以这个代码为例:
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();
}
}
)
我测试过,它在 Flash Player 11 的发布版本中运行良好:
您可以从 here 下载 fla (CS6)、swf 和投影 (.exe)。
希望能帮到你。
任何人都可以告诉我我的退出按钮有什么问题...即使我认为我使用 "fscommand" 当我单击退出按钮时它不会关闭我的 flash 游戏...另一个按钮运行良好。 .
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");
}
在您的 gotoExit 方法中,您写道:
btnExit.addEventListener(MouseEvent.CLICK, gotoExit);
而不是:
btnExit.removeEventListener(MouseEvent.CLICK, gotoExit);
根据 Adobe 的说法,fscommand()
and System.exit()
仅适用于 Flash Player Standalone 版本(System.exit()
的调试器不正确)。
以这个代码为例:
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();
}
}
)
我测试过,它在 Flash Player 11 的发布版本中运行良好:
您可以从 here 下载 fla (CS6)、swf 和投影 (.exe)。
希望能帮到你。