4 Replies Latest reply on Aug 12, 2010 9:44 AM by www.marcelvanduijn.com

    Preload a Flex AIR application in maximized state?

    www.marcelvanduijn.com

      Hello,

       

      I need to develop a desktop application for a client. It will be an SWF based AIR app developed in Flex 3.

       

      Im quite new to Flex and AIR. Does anyone know if its possible to preload an SWF based AIR application with the native window in maximized state? Im afraid this just isnt possible?

       

      The Flex 2-frame preloading model goes through different phases and the Preloader dispatches the following events:

       

      1. ProgressEvent.PROGRESS --> download progress of main SWF (we're in frame 1 of Flex preloading model)
      2. Event.COMPLETE --> main SWF download complete (we're in frame 1 of Flex preloading model)
      3. FlexEvent.INIT_PROGRESS --> initializing the main application (you can defer advancing to frame 2 by defering the dispatch of FlexEvent.INIT_PROGRESS
      4. FlexEvent.INIT_COMPLETE --> initialization of main application complete. Incicates that SystemManager can remove the preloader and add the application to the stage

       

      Now I can ony access WindowedApplication's 'nativeWindow' property and call 'nativeWindow.maximize()' from WindowedApplication's 'creationComplete' handler. WindowedApplication dispatches the FlexEvent.CREATION_COMPLETE event right before the Preloader dispatches the FlexEvent.INIT_COMPLETE. So..... that's at the end of the whole preloading process.

       

      Does this mean I cannot preload a Flex AIR app with the native window in maximized state? Or should you not even visualize preloading of AIR desktop apps?

       

      Any help and tips are greatly appreciated!

       

      Marcel

         

        • 1. Re: Preload a Flex AIR application in maximized state?
          MarkTaylor46 Level 2

          I'm not quite sure exactly what your trying to achieve but, if it's to only show the window once you've maximized it, does setting the windows visibility to false (in MXML) and then changing it to true (in as3) once maximized give you what you were looking for?

           

          Regards,

           

          Mark.

          • 2. Re: Preload a Flex AIR application in maximized state?
            www.marcelvanduijn.com Level 1

            Hi Mark,

             

            thanks for getting back so quickly. What I try todo is preload a Flex SWF based AIR application with the native window in maximized state. Are you familiar with the Flex 2-frame preloading model? (here's a good article on that: http://npacemo.com/wordpress/2008/07/06/flex-application-bootstrapping-totally-custom-prel oader/)

             

            The thing is that the application SWF is preloaded in frame1 of this model. When preloading is finished the application starts to initialize, and just before initialization is complete (before Preloader dispatches FlexEvent.INIT_COMPLETE) WindowedApplication dispatches its CREATION_COMPLETE event. And only then can I access the nativeWindow property and call its maximize method.

             

            What happens this way is that preloading and initialization starts at the width and height as set in the application descriptor file (1024x768 in my case). So the preloading and initialization is visible in a 1024x768 screen. But I want the application to run in maximized mode. When I call nativeWindow.maximize() from the WindowedApplication creationComplete handler, the window jumps from 1024x768 to maximized state. And thats ugly. All that is visible to the user

             

            So I want to preload and initialize in maximized state, and when that is done add the application to the stage. But I cannot set nativeWindow.maximize until the creationComplete event is fired. And when nativeWindow is available, preloading and initialization is already complete... See the problem? Any idea how to go about making work?

             

            Regards,

             

            Marcel

            • 3. Re: Preload a Flex AIR application in maximized state?
              MarkTaylor46 Level 2

              Yes, I agree it's a bit ugly. Did you try my suggestion? or do you actually want to see the preloader?. I tend to keep the initial swf really small and then load modules thereafter - in that way the preloader takes next to no time so you rarely actually see it. I also keep my first window as not visible until I enable it (after my module loading, window sizing/positioning, and other actionscript initialisation is complete).

               

              I only really use flex 4 now so i'm not that familiar with flex 2 preloading events.

               

              Regards,

               

              Mark.

              1 person found this helpful
              • 4. Re: Preload a Flex AIR application in maximized state?
                www.marcelvanduijn.com Level 1

                Hi Mark,

                 

                well, like said Im new to Flex and AIR and not really familiar with the concepts. The idea was to have the preloader visible yes. But I guess the way to go probably is like you said and make the initial load as small as possible and dont show any preloading at all. Maybe this preload procedure is more intended for webprojects.

                 

                Thanks a bunch for your tips. When you're exploring new environments its always very welcome when someone points you in the right direction once in a while

                 

                Regards,

                 

                Marcel