air 2.0 应用程序退出,调用 preventDefault [英] air 2.0 on application quit, call preventDefault
问题描述
试图阻止应用程序在单击 X
按钮时关闭,它仍然关闭,但 AIR 进程正在任务管理器中运行.代码有什么问题?
申请完成:
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting);
结束代码:
私有函数 onExiting(e:Event):void{e.preventDefault();}
尝试 Event.CLOSING
.这就是我用来取消关闭的.
Event.EXITING
发生在窗口被移除之后,应该仅用于清理,而不是阻止应用程序关闭.
来自 文档:><块引用>
在 Windows 上,您将唯一一次获得退出事件是在关闭之后最后一个窗口(当 autoExit=true 时).
<小时>
示例不可关闭"应用程序:
<fx:脚本><![CDATA[导入 mx.controls.Alert;私有函数 init():void{this.addEventListener(Event.CLOSING, function(e:Event):void{e.preventDefault();Alert.show('不可关闭!');});}]]></fx:脚本></s:WindowedApplication>
祝你好运,
阿林
Trying to prevent the application from shutting down when clicked the X
button, it still closing but the AIR process is running in the task manager. What wrong with the code?
Application Complete:
NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting);
Closing code:
private function onExiting(e:Event):void
{
e.preventDefault();
}
Try Event.CLOSING
. That's what I use to cancel closing.
Event.EXITING
happens after the window is removed and should be used only for cleanup, and not to prevent the application from closing.
From the docs:
On Windows, the only time you will get the exiting event is after closing the last window (when autoExit=true).
Sample "unclosable" application:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
initialize="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
private function init():void{
this.addEventListener(Event.CLOSING, function(e:Event):void{
e.preventDefault();
Alert.show('Unclosable!');
});
}
]]>
</fx:Script>
</s:WindowedApplication>
Good luck,
Alin
这篇关于air 2.0 应用程序退出,调用 preventDefault的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!