1 Reply Latest reply on Dec 27, 2010 9:36 AM by Lee Burrows

    Stage always centered

    RaúlKirm

      Hi, I have a Flex 4 application with this code:

       

       

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                     xmlns:s="library://ns.adobe.com/flex/spark" 
                     xmlns:mx="library://ns.adobe.com/flex/mx"                
                     backgroundColor="#000000"
                     applicationComplete="appComp()"
                     width="1600" height="900"
      
      
      
      public function appComp():void{
          
          stage.scaleMode = StageScaleMode.SHOW_ALL;
          stage.align = StageAlign.TOP;
          //stage.align = StageAlign.LEFT;
          
      }
      

       

       

      and in the index.template.html all width and heights are 100%

       

      When I execute the app, and the browser window are resized horizontally, the stage is centered perfectly (StageAlign.TOP), BUT if I try to resize the window vertically, the stage is aligned to the top of the browser. I want that the stage will be always centered but I can set only 1 StageAlign (vertically OR horizontally).

       

      Any idea?

       

      THANKS

      Raúl.

        • 1. Re: Stage always centered
          Lee Burrows Level 4

          Hi

           

          I believe that all flex apps are aligned to the top left - to have a centered content, use an absolute layout with horizontal/verticalCenter="0", eg:

           

          <?xml version="1.0" encoding="utf-8"?>

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

               xmlns:s="library://ns.adobe.com/flex/spark"

               xmlns:mx="library://ns.adobe.com/flex/mx">

           

           

               <s:BorderContainer width="50%" height="50%" horizontalCenter="0" verticalCenter="0" />

           

           

          </s:Application>