2 Replies Latest reply on May 15, 2009 6:39 AM by Cesare Rocchi

    Initial Window

    Saka Nurudeen Level 1

      Hi everybody!

       

      I would like to know how to make an initial

      window described in application.xml

      centered in the screen whatever be dimensions

      of screen.

       

      Please help.

        • 1. Re: Initial Window
          James Whittaker

          Yes easily you can do the following on applicationComplete:

           

          nativeWindow.x = (Capabilities.screenResolutionX - DEFAULT_WIDTH) / 2;

          nativeWindow.y = (Capabilities.screenResolutionY - DEFAULT_HEIGHT) / 2;

           

          That should center your initial window.

          • 2. Re: Initial Window
            Cesare Rocchi Level 2

            You have to set it via code, not in the application.xml

             

            add a listener to the creation complete event

             

            <mx:WindowedApplication ... creationComplete="creationComplete()" />

             

             

            then set x and y like this:

             

            private function creationComplete():void {

                 nativeWindow.x = x;

                 nativeWindow.y = y;

            }

             

            Of course you need to do some calculation to find out monitor's resolution (by means of flash.desktop.Capabilities)

             

            HTH.