Skip to main content
Known Participant
April 11, 2012
Question

Can't seem to control screen orientation on Android

  • April 11, 2012
  • 3 replies
  • 1885 views

I'm trying to use Flash Pro with Air 3.2. I'm used to making apps for iOS and the orientation handling seem much more elegant.

Can someone point me in the right direction for Android. There must be a magic combination of setttings to get this to work?

Trying to use this with Aspect set to Landscape and Orientation set to Auto, but it really freaks out on my Galaxy tab. Keeps switching all the time and rarely matches the orientation I am holind the tablet in.

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangeListener);

var startOrientation:String = stage.orientation;

if (startOrientation == "default" || startOrientation == "upsideDown") {

          stage.setOrientation(StageOrientation.ROTATED_RIGHT);

} else {

          stage.setOrientation(startOrientation);

}

function orientationChangeListener(e:StageOrientationEvent) {

          if (e.afterOrientation == "default" || e.afterOrientation == "upsideDown") {

                    e.preventDefault();

          }

}

EDIT: I'm using a Galaxy Tab to test if that matters. It seems like my device is pretty slow to react to orientation on the desktop, but it goes haywire in my app.

Thanks for any help you can provide.

This topic has been closed for replies.

3 replies

spinlightAuthor
Known Participant
April 12, 2012

I guess if this is a feature in 3.3 it must be know to not work in 3.2?

http://labs.adobe.com/technologies/flashplatformruntimes/air3-3/

"Aspect Ratio Enhancements — With AIR 3.3 the issue with the runtime ignoring the specified aspect ratio has been resolved. In this release we address this use-case by allowing only screen orientation corresponding to app specified aspectRatio and orientation corresponding to 180 degree device rotation from the specified aspectRatio."

Is there a workaround? Is it possible to prevent portrait view on a landscape app under 3.2? I can't get it to not distort my app to a portrait view.

Inspiring
April 12, 2012

I have the same problem with changing orientation dynamically, it blinks and performs strange.

Participant
April 11, 2012

Hi,

I think setOrientation has been deprecated.

have you tried

 

stage.setAspectRatio(StageAspectRatio.LANDSCAPE);

instead?

/Lars

spinlightAuthor
Known Participant
April 11, 2012

So is the idea to use StageOrientationEvent.ORIENTATION_CHANGING in combination with stage.setApsectRatio?

spinlightAuthor
Known Participant
April 11, 2012

It's like it has to stop and try at every rotation point in between as well. So it distorts my app for a moment while it works it's way to my current orientation. It's such a struggle to have our apps launch cleanly and handle orientation from Air version to Air version. I've never had it working well on Android so I feel like I'm missing something. Just want it to be landscape and have only two possible views. 0 and 180 degrees.