user2158208
user2158208

Reputation: 51

AS3/Adobe AIR Starting in Portrait & changing to Landscape becomes wrong

I'm gonna try to explain this as good as I can with limited english!

Ok, I'm bulding an app that will on phones be in portrait mode and in landscape on tablets. I do this by, first with calculating the display size than basically saying "if display size is more than 5 inches, consider this device to be a tablet".

This works great. I'm using Adobe Flash CS6 with FlashDevelop, so I have portrait mode as default once the application start. If the device is a tablet, it changes aspect ratio with stage.setAspectRatio(StageAspectRatio.LANDSCAPE);

This also works great. Now, the problem is that stage.stageWidth will not change its value to the new aspectRatio. This is a easy fix with just using stage.stageHeight for the width. BUT the system bar on honeycomb/ics tablets/devices will not be changed.

Sorry for the bad explanation but let me show you with some numbers...

This is what happends when I start my application on my tablet.

  1. Application start with Portrait. The height = 1232 width = 800. As you can see the display resolution should be 1280x720 but there is no way to get the height of the systembar througout any commands. I've test everything that returns resolution and none of them return the full resolution (1280x720).

  2. Now the application turns into landscape (since it's a tablet) and gets this resolution height: 800, width 1232.

As you may can imagine this is wrong. Because the systembar is on the bottom. The resolution should be height: 752, width 1280.


Is there any solutions? I've been thinking of a workaround that will basically calculate what the systembar *should be. But before I start on that, I would like to know if there is any way to solve this.*

Upvotes: 1

Views: 2040

Answers (1)

bikutaa
bikutaa

Reputation: 33

-1. I don't know if there's an official way to do these, but your first criteria sounds similar to this:

link: AS3/AIR: If phone use portrait, if tablet use landscape?

This also solves the problem that some devices' default orientation are "portrait" but some devices' are "landscape"

-2. As for the area of the screen

The following should give the pixel dimensions of the device:

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

//import flash.system.Capabilities;
Capabilities.screenResolutionX;
Capabilities.screenResolutionY;

And then using this (which I assume you've been using) should return the usable area minus the Status Bar (a post I read mentioned it is correct for iPad but some Android tablets did not take into account the Navigation Bar):

stage.stageWidth;
stage.stageHeight;

Then this one should give the correct value of screen resolution minus Status Bar and Navigation Bar area:

//import flash.display.Screen
var screenBounds:Rectangle = Screen.mainScreen.visibleBounds;

Upvotes: 1

Related Questions