Issue with Event.EXITING in AIR 2.5
I am facing an issue with the Exiting event in AIR when creating my application using Flash builder. The exiting event does not function on windows shutdown... howevere if I click the 'X' button to exit the app it works perfectly fine....is there a bug in the exiting event...
<?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"
creationComplete="init()"
styleName="plain" width="100%" height="100%">
<fx:Script>
<![CDATA[
import flash.events.Event;
import mx.controls.Alert;
protected function init():void
{
trace("handle exit");
NativeApplication.nativeApplication.addEventListener(Event.EXITING,handleExiting);
}
public function handleExiting(e:Event):void
{
Alert.show("Exit!");
trace("Handle Exit!!");
var f:File = File.desktopDirectory;
f = f.resolvePath("air-exit-test.txt");
var stream:FileStream = new FileStream();
stream.open(f,FileMode.WRITE);
stream.writeUTFBytes(ta.text);
stream.close();
}
]]>
</fx:Script>
<s:Panel width="100%" height="100%" title="Exit Event on Shutdown">
<s:HGroup width="95%" left="10" top="10">
<s:Label text="Enter text to save upon shutdown:"/>
<s:TextArea id="ta" height="200"/>
<s:Label width="95%" verticalAlign="justify" color="#323232" horizontalCenter="0" bottom="20"
text="The Exiting event can now be handled upon the user shutting down the OS giving you a chance to handle any unsaved data in your application upon shutdown. If you run this code in an AIR application and shutdown your OS, it will still save the data that you have entered in Text Area to air-exit-test.txt in your Desktop directory."/>
</s:HGroup>
</s:Panel>
</s:WindowedApplication>
