Skip to main content
Participant
March 29, 2011
Answered

Air 2.6 Screen orientation

  • March 29, 2011
  • 2 replies
  • 2956 views

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 has been closed for replies.
Correct answer Colin Holgate

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.

2 replies

Colin Holgate
Colin HolgateCorrect answer
Inspiring
May 5, 2011

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.

June 30, 2011

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!

Pahup
Adobe Employee
Adobe Employee
June 30, 2011
Adobe Employee
March 29, 2011

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.

Alf_AlfAuthor
Participant
March 29, 2011

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.