2 Replies Latest reply on Sep 8, 2009 9:22 PM by dkelly60

    problem exiting application

    dkelly60

      I have an aplication that I have been working on in flash CS4, it is an air application. When I close the application using the main windows close button it appears to close but is still running when I look at processes.

      If I close it by calling exit from the main menu it closes properly. I guess I am probably missing something obvious but I am not sure what.

       

      I set up a listener for the application

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

      and I setup a loop in the onExiting function to dispatch a closing event to application windows check to see if it's prevented and if not close the window.

       

      However on testing the onExiting function is not being called when I close the application from the main window clsoe button, only form when I use the menu.

       

      To try and see what is causing the problem I did a trace on the loop for open application windows. there are 2 one is the main program and the other is untitled both are normal windows. Since only use one window in my application I don't understand why there are 2. But I guess it's the unclosed window that is keeping the program from closing.

       

      any help will be appreaciated.

        • 1. Re: problem exiting application
          dkelly60 Level 1

          Ok this is starting to look like a bug in air or flash cs4.

           

          I have stripped the program down to a window that opens , an exiting event listener and an onExiting function.

           

          The onExiting function is called intermittently I have not been able to work out when it will occur and when it wont, it seems to occur about 1 in 10.

           

          here is the output when run

          [SWF] wizard.swf - 2040 bytes after decompression
          setting listener
          Test Movie terminated.

           

          when it works

          [SWF] wizard.swf - 2040 bytes after decompression
          setting listener
          exit called for
          Test Movie terminated

           

          I have attached the files can someone else test them?

          • 2. Re: problem exiting application
            dkelly60 Level 1

            Ok this is really really frustrating. This blo*dy forum system is cr*p I have lost my message three times and if this gets through its a miracle.

             

            anyway my message

            It is beginning to look like a but in AIR or flash CS4, I have stripped the program I was working on down to a window, an event listener and a function to handle the event.

             

            here is the contents of the wizard.as file

             

            package {
                import flash.display.*;
                import flash.events.*;       
                import flash.display.NativeWindow;
                import flash.desktop.NativeApplication;

             

                public class wizard extends Sprite {       
                   
                    public function wizard():void
                    {           
                        NativeApplication.nativeApplication.autoExit = true;           
                        NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting);
                        trace("setting listener");
                               
                    }

             

                    function onExiting(e:Event):void
                    {
                        trace("exit called for ");                       
                    }   
                }
            }

             

            I will try to attach the files but it has not work 3 times so far.

             

            When I close the wizard via the close button I get intermittent operation of the event, it works about 1 in 10 times I run the program. I have not been able to tell when it will or will not work.

             

            here is the output

             

            when it works

            [SWF] wizard.swf - 2040 bytes after decompression
            setting listener
            exit called for
            Test Movie terminated.

             

            when it doesn't

            [SWF] wizard.swf - 2040 bytes after decompression
            setting listener
            Test Movie terminated.