3 Replies Latest reply on Jan 5, 2010 10:16 PM by Umal Kumar

    I want my app to be driven with APP_EXIT.

    Purume77
      I created ActionScript project application in Flex 3.0

      I want my app get exit event when it is closed like an usual event driven application.
      because I 'd like to do something, right before the flex app is closed.

      when application is terminated. for instance,
      When web brower which embed the .swf is closed by user.

      Actually, I tried addEventListener like the below

      this.addEventListener(Event.UNLOAD, close_handler);
      this.addEventListener(Event.CLOSE, close_handler);

      private function close_handler(e:Event):void {
      }

      but it is not driven ever.



        • 1. Re: I want my app to be driven with APP_EXIT.
          Level 7

          "Purume77" <webforumsuser@macromedia.com> wrote in message
          news:gj9pi8$iul$1@forums.macromedia.com...
          >I created ActionScript project application in Flex 3.0
          >
          > I want my app get exit event when it is closed like usual event driven
          > application.
          > because I 'd like to do something, right before the flex app is closed.
          >
          > when application is terminated. for instance,
          > When web brower which embed the .swf is closed by user.
          >
          > Actually, I tried addEventListener like the below
          >
          > this.addEventListener(Event.UNLOAD, close_handler);
          > this.addEventListener(Event.CLOSE, close_handler);
          >
          > private function close_handler(e:Event):void {
          > }
          >
          > but it is not driven ever.

          You need to use JavaScript on the page to detect beforeUnload and call
          something in your swf.


          • 2. Re: I want my app to be driven with APP_EXIT.
            ntsiii Level 3
            As Amy says. But google this. There are browser version issues. And lots of discussion and examples are available.
            Tracy
            • 3. Re: I want my app to be driven with APP_EXIT.
              Umal Kumar Adobe Employee

              if you wanted to just close the window all together you could write some Javascript to close the window, then in your flex app call the function when they click the logout button

               

               

              If you want to actually end it with Actionscript you could try:

               

               

              public function applicationExit():void {   

                   var exitingEvent:Event = new Event(Event.EXITING, false, true);   

                   NativeApplication.nativeApplication.dispatchEvent(exitingEvent);   

                   if (!exitingEvent.isDefaultPrevented()) {       

                        NativeApplication.nativeApplication.exit();  

                    }

              }

               

              Source: http://livedocs.adobe.com/flex/3/html/help.html?content=app_launch_1.html

               

              UKB