1 Reply Latest reply on Dec 24, 2013 6:58 PM by fB3

    Orientation Change?

    xp3tp85

      I am developing an app for Android and iOS and I want to know how to make the app orientation change with the device orientation from portrait to landscape.

       

      Is there a way to make the same frame twice for each orientation and have it load the appropriate instance automatically? I would need it to load the 480x800 for portrait and then 800x480 for landscape. I would need it to stay on the correct frame as well. If I am on the contents page, I need it to stay on the contents page and not return to the main menu upon rotation.

       

      If there is a better way to do this, which I'm sure there is, please let me know! Thanks!

        • 1. Re: Orientation Change?
          fB3 Level 2

          Here is a simple method just add this to a new layer on frame 1 of the timeline
          Make sure the new layer spans the whole timeline not just 1 frame.

           

            stage.scaleMode = StageScaleMode.NO_SCALE;
          stage.align = StageAlign.TOP_LEFT;

           


          stage.addEventListener(Event.RESIZE, resizeHandler);
          var isLandscape:Boolean;

           


          function resizeHandler(e:Event):void
          {
              if ( stage.stageWidth > stage.stageHeight )
              {
                  isLandscape = true;
                  goToAndStop( 10 ); 
                 }
              else
              {
                  isLandscape = false;
                  goToAndStop( 5 );
              }
          };

          1 person found this helpful