Skip to main content
Participant
Mar 8, 2011 11:25 AM UTC
Question

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>

This topic is closed to new replies. Start a new post to keep the conversation going.

11 replies

Known Participant
May 28, 2015 10:45 AM UTC

The problem is still alive for current version

AIR runtime version 17.0.0.172, patchLevel 172

Translate
piyushb89979246
Adobe Employee
Adobe Employee
May 28, 2015 11:34 AM UTC

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

Translate
Known Participant
May 29, 2015 9:25 AM UTC
Participant
Mar 9, 2011 5:45 AM UTC

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

Translate
Mar 9, 2011 9:07 PM UTC

Try Event.CLOSING?


Translate
chris.campbell
Legend
Mar 10, 2011 1:53 AM UTC

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

Translate