Skip to main content
Participant
Mar 29, 2011 6:34 AM UTC
Answered

Air 2.6 Screen orientation

I'm trying to get this Air 2.6 feature to work again.

http://kb2.adobe.com/cps/891/cpsid_89107.html

Changes in AIR 2.6

Screen orientation changes in 2.6 namespace

Based on the release doc, it says "The swf is required to be compiled with the flag "-target-player=11" to make use of supportedOrientations API."

How do I "compile with the flag" ???

I'm using Flash CS5 to publish .swf

I got the adt cmd line working.

My AS3 script:

addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, onOrientationChange);

function onOrientationChange(event:StageOrientationEvent):void {

     trace("onOrientationChange:"+event.afterOrientation);

    ...and process result.

    }

}

Thanks,

Alfred

This topic is closed to new replies. Start a new post to keep the conversation going.
Colin Holgate
Colin HolgateCorrect answer
Inspiring
May 5, 2011 10:38 PM UTC

StageOrientationEvent.ORIENTATION_CHANGE and StageOrientationEvent.ORIENTATION_CHANGING are not part of the supportedOrientations API. If you want to prevent Portrait, you can do that like this:

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChanging);

private function orientationChanging(e:StageOrientationEvent) {

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

e.preventDefault();

}

}

That trick will work with AIR 2.0 as well as AIR 2.6, and without requiring player 11.

7 replies

Colin Holgate
Colin HolgateCorrect answer
Inspiring
May 5, 2011 10:38 PM UTC

StageOrientationEvent.ORIENTATION_CHANGE and StageOrientationEvent.ORIENTATION_CHANGING are not part of the supportedOrientations API. If you want to prevent Portrait, you can do that like this:

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChanging);

private function orientationChanging(e:StageOrientationEvent) {

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

e.preventDefault();

}

}

That trick will work with AIR 2.0 as well as AIR 2.6, and without requiring player 11.

Translate
Jun 30, 2011 7:48 AM UTC

Hi.

somehow I have a Problem with this sollution because the StageOrientationEvent.ORIENTATION_CHANGING does'nt get triggerd.

The ORIENTATION_CHANGE works fine but.

Using Flash 5.5. on Android with Air 2.7.0.1948.

Please help, I'Am going crazy right now!

Translate
Pahup
Adobe Employee
Adobe Employee
Jun 30, 2011 7:58 AM UTC
Adobe Employee
Mar 29, 2011 7:30 AM UTC

Right click the Project->Properties->Flex Library Compiler.

In the Additional compiler arguments, you need to append -target-player=11.

Build the preject again.

I hope it solves your problem.

Translate
Alf_AlfAuthor
Participant
Mar 29, 2011 7:38 AM UTC

Thanks, but I'm on Flash CS 5, not Flex.

It has Pubish Settings, but I don't know where to fill in this flag.

Thanks anyways.

Translate