2 Replies Latest reply on Sep 8, 2009 6:28 PM by dkelly60

    close button autoexit

    dkelly60

      How do I respond to an autoexit when the application window is closed.

       

      according to the AIR 1.5 docs

      "When an exit command is mediated through the operating system by one of these routes, the NativeApplication dispatches an exiting event. If no listeners cancel the exiting event, any open windows are closed. Each window dispatches a closing and then a close event. If any of the windows cancel the closing event, the shut-down process stops."

       

      I have tried adding an event listener in the constructor for the application

       

      this.addEventListener(Event.EXITING,onExiting);

       

       

      AutoExit is set to true, the application terminates when the window close button is used but no EXITING event is recieved therefore onExiting is not executed.

       

      Can someone show me the correct way to do it?

        • 1. Re: close button autoexit
          Jeff Swartz Level 3

          Are you cancelling the event (by calling the preventDefault() method)? The following should work:

           

          NativeApplication.nativeApplication.autoExit = true;
          NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting);

           

          function onExiting(event:Event):void
          {
              event.preventDefault();
              trace("onExiting() handler");
          }               

          • 2. Re: close button autoexit
            dkelly60 Level 1

            Ok so

            this.addEventListener(Event.EXITING,onExiting);

             

            does not work but

            NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting);


            does

            Thank you.