Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
Hey guys.. any help on the above issue.... or is there something really simple that I am missing.
Copy link to clipboard
Copied
Try Event.CLOSING?
Copy link to clipboard
Copied
I'm looking into this. I tried with:
this.addEventListener(Event.CLOSING, handleExiting); this.addEventListener(Event.UNLOAD, handleExiting);
and found that handleExiting() was skipped when I shutdown/restarted Windows 7. I've pinged others on the team and hope to have more info soon.
Thanks,
Chris
Copy link to clipboard
Copied
Hi Chris,
I'm really looking forward to getting this resolved. I have another question regarding the above issue, normally if the event worked then will it only allow the user to do something locally or can I also add a record to an online database table. This is what I'm actually trying to do, the above code is just to test it on the same PC itself.
Thanks for looking into this
--Ashwin
Copy link to clipboard
Copied
Hey Chris any updates on the issue?
Copy link to clipboard
Copied
Thanks for bringing this back up. I ended up adding this as a new bug (internal bug #2827751). There's no update yet but I'm hoping we can address this in a future release.
Thanks,
Chris
Copy link to clipboard
Copied
Has this issue now been fixed? Since we can't track internal bugs I've no idea what is happening with this. There have been several AIR releases since 2.5.
Copy link to clipboard
Copied
This bug has not been fixed as of AIR 2.7, I don't have a date/version I can give you when this will be addressed.
However, I would recommend adding a new bug to bugbase.adobe.com and include the sample project and a reference to our internal bug number. The public bug will then be linked to our internal bug and you'll be able to see updates as the state and status are changed. If you post back with the public bug URL, others effected can cast their votes and add notes as well.
Thanks,
Chris
Copy link to clipboard
Copied
The problem is still alive for current version
AIR runtime version 17.0.0.172, patchLevel 172
Copy link to clipboard
Copied
Hi Dmitry,
Thank you for the heads up. Can you please open a bug report at https://bugbase.adobe.com ,so that we can set this problem as a new feature request.
Also we recommend anyone who is effect by this issue give it a vote, and leave a comment on how it impact your work and development so that we can adjust its priority accordingly.
Thanks
Adobe AIR Team
Copy link to clipboard
Copied