我正在创建一个将以exe
格式导出的Flash应用程序,它不会在浏览器中运行。我想在舞台内添加一个退出按钮,但我不知道如何使用ActionScript 3。
我记得在ActionScript 2中可以使用fscommand
,但它在AS3中不起作用。
我到处搜索,但每个人都试图在浏览器环境中关闭弹出窗口或标签或窗口而不是Flash应用程序。
答案 0 :(得分:9)
为什么现在可以将as3应用程序导出为AIR时使用.exe格式? 但 如果你仍然需要exe,我认为这将有效
import flash.system.fscommand;
//Then you can use the following function for the button click handler:
private function clickHandler(event:MouseEvent):void {
fscommand("quit");
}
如果您决定尝试AIR解决方案,这是命令
import flash.desktop.NativeApplication;
nativeApp.nativeApplication.exit();
答案 1 :(得分:4)
它仍然是fscommand
,但语法不同:
import flash.system.fscommand;
btn.addEventListener(MouseEvent.MOUSE_DOWN, closeApp);
function closeApp(event:MouseEvent):void {
fscommand("quit");
}
答案 2 :(得分:3)
System.exit(0);应该关闭桌面应用程序吗?
答案 3 :(得分:3)
尝试:
import flash.system.fscommand;
function clickHandler(event:MouseEvent):void {
fscommand("quit");
}
btn.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler);
答案 4 :(得分:0)
function exitAdobe (event:MouseEvent): void {
NativeApplication.nativeApplication.exit();
}
bt_exit.addEventListener(MouseEvent.CLICK, exitAdobe);
//A melhor forma que encontrei...