Skip to main content
Pouradam
Inspiring
February 13, 2014
Answered

disable Auto Orientation only in a specific frame!

  • February 13, 2014
  • 1 reply
  • 379 views

Hi there! 

I appreciate if you please guide me with your experience in Mobile App design.

My App contains 5 frames of data (movieclips), that each frame has 2 designs:

1- Stand mode design    (portrait)

2- Wide mode design     (landscape)

So far it works great and I have published my App both on Google Play and Apple Store.

Frames structure is as follows:

frame   1            Loads External Data

frames 2-6         Each frame contains 1 MovieClip designed based on mobile "Stand mode"

frames 22-26     Each frame contains 1 MovieClip designed based on mobile "Wide mode"

(Example: contents of frame 2 and 22 are the same, also 3 & 23 ... 6 & 26)
(frame 2 is STAND design, 22 is WIDE design, and so on)

In "Air Setting Dialoge", I have selected aspect ratio "Auto" and "Auto orientation".

And I have this code in Frame 1 to do the rotation trick:

stage.addEventListener(Event.RESIZE, resizeLayout);

 

function resizeLayout(e:Event):void

{

               setPosition();

}

function setPosition():void

{

        //Phone turned from "Wide" to "Stand"

               if (stage.stageWidth < stage.stageHeight)

               {

                              //App is now in "Wide" mode - means between frame 22 to 26

                              if (currentFrame>20) 

                              {

                                             //go to the same position of App but in "Stand" mode

                                             gotoAndStop(currentFrame - 20);

                              }

               }

               else

               {

                              //Phone turned from "Stand" to "Wide"

                              if (currentFrame<20)

                                   {

                    //go to the same position of App but in "Wide" mode 

                     gotoAndStop(currentFrame + 20);

                                   }

                         }

}

Well, and finally my question:

1- Is this way I have programed my App to rotate, a proper approach?!

      (in this way I can easily arrange objects on screen and also position them based on math calculations)

2- If I want to disable auto rotation only when app reaches specific frames, what should I do??

   (for example I want the app Not to auto oriente in Frame 6 and 26., but it rotates in other frames)

Hope it was not confusing and I cant wait to check out your valuable guidance!

All the best and thanks a lot for your time.

This topic has been closed for replies.
Correct answer Pouradam

Hi there all!!

Still I have no answer for my question No1, BUT I could find my answer to the 2nd question and here it is for your kind notice:

Special thanks to Daniel Dura

http://www.adobe.com/devnet/flash/articles/screen_orientation_apis.html

I just added this code to my first Frame:

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, onOrientationChanging);

function onOrientationChanging(event:StageOrientationEvent ):void

{

          if (currentFrame == 6 || currentFrame == 26)

          {

                    event.preventDefault();

          }

}

1 reply

Pouradam
PouradamAuthorCorrect answer
Inspiring
February 13, 2014

Hi there all!!

Still I have no answer for my question No1, BUT I could find my answer to the 2nd question and here it is for your kind notice:

Special thanks to Daniel Dura

http://www.adobe.com/devnet/flash/articles/screen_orientation_apis.html

I just added this code to my first Frame:

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, onOrientationChanging);

function onOrientationChanging(event:StageOrientationEvent ):void

{

          if (currentFrame == 6 || currentFrame == 26)

          {

                    event.preventDefault();

          }

}