1 Reply Latest reply on Nov 8, 2011 3:54 AM by flexercised

    View resizes when it shouldn't

    flexercised Level 3

      http://www.adobe.com/devnet/flex/articles/mobile-development-flex-flashbuilder.html#articl econtentAdobe_numberedheader_1

       

      On this page it says: "When the user rotates the screen between portrait and landscape orientations, the View is automatically resized by default to the appropriate aspect ratio."

      How can this be prevented i.e. make the view keep the same size?

       

      If you use the screen orientation apis to confine the app to 2 orientations (rotated left and right), you can prevent the app rotating but the view resizes anyway.

        • 1. Re: View resizes when it shouldn't
          flexercised Level 3

          Try this:

           

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

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

                  addedToStage="initView()">

           

              <fx:Script>

                  <![CDATA[

                  import flash.display.StageOrientation;

                  import flash.events.StageOrientationEvent;

           

                  private function initView():void {

                     stage.addEventListener( StageOrientationEvent.ORIENTATION_CHANGING, onOrientationChanging );

                  }

           

                  private function onOrientationChanging( event:StageOrientationEvent ):void {

                      if (event.afterOrientation == StageOrientation.DEFAULT || event.afterOrientation == StageOrientation.UPSIDE_DOWN )

                          event.preventDefault();

                  }

                  ]]>

              </fx:Script>

           

                  <s:Rect height="100%" width="100%">

                      <s:fill><s:SolidColor color="red" /></s:fill>

                  </s:Rect>

           

              <s:Label text="Hello World" horizontalCenter="0" verticalCenter="0"/>

          </s:View>

           

          In the app xml:

          <aspectRatio>landscape</aspectRatio>

          <autoOrients>true</autoOrients>

          <visible>true</visible>

           

          Start the app on the ipad in landscape orientation. Turn it 90°. The red shape and actionbar do not fill the screen any more.

          Any solution?