Skip to main content
Participant
November 9, 2011
Answered

StageOrientationEvent strange behaviour

  • November 9, 2011
  • 1 reply
  • 960 views

Hate to bring this up again but I've been tearing my hair out trying to get to the bottom of this.

We are developing a game that needs to be submitted to the apple app store, so we also need to support the two possible landscape modes.

I've been using the snippets mentioned here http://forums.adobe.com/message/4007439#4007439 and here http://www.adobe.com/devnet/flash/articles/screen_orientation_apis.html but so far nothing is stopping the app from using portrait mode when it feels like it wants to.

Couple of special mentions,

When testing on android and listening for StageOrientationEvent.ORIENTATION_CHANGING I get nothing. This event just doesn't fire at all.

However, StageOrientationEvent.ORIENTATION_CHANGE does fire. If I try to intercept this with the following

if (e.afterOrientation == StageOrientation.DEFAULT || StageOrientation.UPSIDE_DOWN)

{

                                        e.preventDefault();

}

it prevents the stage rotation on the first event, but on further changes it appears to ignore preventDefault(); and jumps to one of the portrait modes.

I'm currently trying to debug on an iPad as well but can't see the traces as yet. Either way, neither of these methods seems to give the required (or indeed needed) behaviour.

I've broken just these bits out to a seperate test app in order to test and am happy to drop that somewhere if someone can suggest a fix.

In the meantime any tips at all would be greatly received. Thanks in advance,

Mark

This topic has been closed for replies.
Correct answer timothyrandall

The code I posted in the linked discussion works every time for me on my iPad. I'm running AIR 2.6 though...perhaps you could try compiling in that and seeing if it works? The only other thing I can think of suggesting is to make sure that autoOrients is set to true within your app descriptor.

1 reply

timothyrandallCorrect answer
Participating Frequently
November 10, 2011

The code I posted in the linked discussion works every time for me on my iPad. I'm running AIR 2.6 though...perhaps you could try compiling in that and seeing if it works? The only other thing I can think of suggesting is to make sure that autoOrients is set to true within your app descriptor.

desmarkieAuthor
Participant
November 11, 2011

Very strange. I think there may have been as issue with trying to use the same setup for Android and iOS.

Originally the main.as was forcing the stage orientation to landscape, as for some reason it wasn't behaving on android.

Having removed that section and just leaving the event listener everything works fine on iPad.

Cheers, for the input, sorry for spamming the board

Mark