Skip to main content
Participant
March 8, 2011
Question

Issue with Event.EXITING in AIR 2.5

  • March 8, 2011
  • 2 replies
  • 2577 views

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>

This topic has been closed for replies.

2 replies

Known Participant
May 28, 2015

The problem is still alive for current version

AIR runtime version 17.0.0.172, patchLevel 172

piyushb89979246
Adobe Employee
Adobe Employee
May 28, 2015

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

Known Participant
May 29, 2015
Participant
March 9, 2011

Hey guys.. any help on the above issue.... or is there something really simple that I am missing.

March 9, 2011

Try Event.CLOSING?


chris.campbell
Community Manager
Community Manager
March 10, 2011

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