AIR 2.0应用程序退出,调用preventDefault [英] air 2.0 on application quit, call preventDefault
问题描述
试图prevent应用从什么时候点击关闭X
按钮,它仍然关闭,但AIR过程是在任务管理器运行。有什么不对的code?
应用程序完成:
NativeApplication.nativeApplication.addEventListener(静态] Event.EXITING,onExiting);
结算code:
私有函数onExiting(五:事件):无效
{
即preventDefault();
}
尝试 Event.CLOSING
。这是我用它来取消收什么。
静态] Event.EXITING
发生在窗口移开后,只进行清理,应使用,而不是prevent从关闭应用程序
从文档:
在Windows中,唯一的一次,你会得到 在退出事件是在关闭后, 最后一个窗口(当AUTOEXIT = TRUE)。
样本不可关闭应用程序:
< XML版本=1.0编码=UTF-8&GT?;
< S:的WindowedApplication的xmlns:FX =http://ns.adobe.com/mxml/2009
XMLNS:S =库://ns.adobe.com/flex/spark
的xmlns:MX =库://ns.adobe.com/flex/mx
初始化=的init()>
< FX:脚本>
<![CDATA [
进口mx.controls.Alert;
私有函数的init():无效{
this.addEventListener(Event.CLOSING,功能(五:事件):无效{
即preventDefault();
Alert.show('不可关闭!');
});
}
]]≥
< / FX:脚本>
&所述; /秒:的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屋!