Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

stage orient

Contributor ,
Mar 06, 2014 Mar 06, 2014

My app is set to auto orient and auto aspect ratio in the app descriptor.  At a certain point, I want to disable it from orienting.  If I call:

stage.autoorients=false;

it works for portrait but if it is called when in landscape, it changes back to portrait instead of freezing it in landscape.  Is it actually loading the default instead of just disabling?

TOPICS
Development
793
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 06, 2014 Mar 06, 2014

That’s interesting, and might make sense in some way I suppose.

You can easily work around the issue by setting the stage orientation to what it was before you turned of auto orients.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 06, 2014 Mar 06, 2014

Guess I should state this is for Android, I don't believe it works the same for iOS.  I can set the orient manually to what it is, just wondering if this is expected behavior or a bug.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 06, 2014 Mar 06, 2014

BTW - I set it using stage.setAspectRatio(stageAspectRatio.LANDSCAPE) and it still didn't work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 06, 2014 Mar 06, 2014

Does the refresh function on this page help?:

http://help.adobe.com/en_US/as3/dev/WS901d38e593cd1bac1c39723e12caaf5620c-7fff.html

Note the mildly confusing fact that you for landscape you set the stage orientation to the opposite of what the device is reporting.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 06, 2014 Mar 06, 2014

I am not sure I understand the comment on what is mildly confusing. 

In summary, if in Landscape, I want it to stay in Landscape while doing a particular task.  If in portrait, I want to stay in portrait for that same task.  It all depends on how they started the task.  What was happening was when in landscape (on my phone), setting autoorients=false changed it to portrait (likely the default orientation for phones).  I would have expected that it would just stop changing orientation from then on but it doesn't seem to work that way.

I did fix it using stage.setAspectRatio(stageAspectRatio.LANDSCAPE).  The reason it didn't work the first time is because I kept the statement autoorients=false in there.  If you set it to Landscape with autoorient still true (from app descriptor), it will only autoorient to landscape and landscape upside down.  Then when I want to rotate again with portrait (post task completion), I just used the stage.setAspectRatio(stageAspectRatio.ANY)

Anyway, appreciate the speedy responses.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 06, 2014 Mar 06, 2014
LATEST

Good solution to the problem. Another approach you could have used was to listen for the orientation changing event, and only allow it through if the intended orientation was one you wanted.

The confusing part I was referring to was that if you detect the device is one way in landscape, you rotate the stage the other way. For example:

if (theStage.deviceOrientation==StageOrientation.ROTATED_RIGHT){

theStage.setOrientation( StageOrientation.ROTATED_LEFT );

}

That’s because it describes the rotation of the stage that is needed to counteract the rotation of the device, to then keep the stage upright.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines