5 Replies Latest reply on Aug 18, 2010 10:14 PM by iamcootis

    Centering a fixed size air application when maximized

    iamcootis Level 1

      I have a fixed-sized air application that when maximized I want it to be centered on the user's screen. Currently when it is maximized it goes to the top left corner of the screen. Is there any way I can make this centered?

        • 1. Re: Centering a fixed size air application when maximized
          Subeesh Arakkan Level 4

          Hi,

           

          Try this after maximized.

           

          this.move( (Capabilities.screenResolutionX - this.width)/2, (Capabilities.screenResolutionY - this.height)/2 );
          
          • 2. Re: Centering a fixed size air application when maximized
            iamcootis Level 1

            That didn't work. Nothing changed.


            • 3. Re: Centering a fixed size air application when maximized
              Subeesh Arakkan Level 4

              Hi,

               

              I think it is your main container not the application. Check if it is centered .

              • 4. Re: Centering a fixed size air application when maximized
                iamcootis Level 1

                My application looks like this. What would you consider my main container?

                 

                <?xml version="1.0" encoding="utf-8"?>
                <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="700" width="768"
                    paddingLeft="5" paddingRight="5" paddingTop="5" paddingBottom="5"
                     alpha="1.0" borderColor="#FFFFFF"
                     xmlns:components="com.components.*"
                    applicationComplete="init()" xmlns:views="views.*" verticalScrollPolicy="off" horizontalScrollPolicy="off" showStatusBar="false">


                    <components:Header id="header" x="0" y="0" width="768"/>
                    <mx:ViewStack id="mainViewStack" selectedIndex="{ApplicationModel.instance.viewState}" x="2" y="52" height="608">
                        <views:LessonView x="0" y="50" height="608" id="mainLessonView" creationPolicy="queued" creationIndex="1" />
                        <views:ChooseLessonsView x="0" y="50" height="608" id="mainChooseLessonView" />
                        <views:HelpView x="0" y="50" id="mainHelpView" creationPolicy="queued" creationIndex="2" height="608"/>
                        <views:FAQView x="0" y="50" id="mainFAQView" creationIndex="5" creationPolicy="queued" height="608"/>   
                        <views:LoginView x="0" y="50" id="mainLoginView" creationPolicy="queued" creationIndex="4"  height="608"/>
                    </mx:ViewStack>
                   
                   
                    <components:Footer height="40" x="0" y="660" width="768"/>

                 

                       

                 

                   
                </mx:WindowedApplication>

                • 5. Re: Centering a fixed size air application when maximized
                  Subeesh Arakkan Level 4

                  Hi,

                   

                  The issue is because you are using fixed height, width and absolute positioning. I have introduced a Canvas as an outer container

                   

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="700" width="768" 
                      paddingLeft="5" paddingRight="5" paddingTop="5" paddingBottom="5"
                       alpha="1.0" borderColor="#FFFFFF" 
                       xmlns:components="com.components.*"
                      applicationComplete="init()" xmlns:views="views.*" verticalScrollPolicy="off" horizontalScrollPolicy="off" showStatusBar="false">
                  
                  <mx:Canvas height="700" width="768" verticalCenter="0" horizontalCenter="0">
                      <components:Header id="header" x="0" y="0" width="768"/>
                      <mx:ViewStack id="mainViewStack" selectedIndex="{ApplicationModel.instance.viewState}" x="2" y="52" height="608">
                          <views:LessonView x="0" y="50" height="608" id="mainLessonView" creationPolicy="queued" creationIndex="1" />
                          <views:ChooseLessonsView x="0" y="50" height="608" id="mainChooseLessonView" />
                          <views:HelpView x="0" y="50" id="mainHelpView" creationPolicy="queued" creationIndex="2" height="608"/>
                          <views:FAQView x="0" y="50" id="mainFAQView" creationIndex="5" creationPolicy="queued" height="608"/>    
                          <views:LoginView x="0" y="50" id="mainLoginView" creationPolicy="queued" creationIndex="4"  height="608"/>
                      </mx:ViewStack>
                      
                      
                      <components:Footer height="40" x="0" y="660" width="768"/>
                  
                   </mx:Canvas>      
                  
                      
                  </mx:WindowedApplication>