Copy link to clipboard
Copied
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
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
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,
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
ORIENTATION_CHANGING does not get fired on AIR on Android.
-Pahup
Copy link to clipboard
Copied
Wow. Thats ... bad. Any other workarounds to get the rotation event without changing the orientation automaticly?
ok i make it that way now
http://www.adobe.com/jp/joc/devnet/air/articles/air_android_orientation2.html
is it a hardware issue that it does not work on android? oder the os?
Copy link to clipboard
Copied
It is an OS issue, AFAIK. If you are just trying to detect orientation, you can use the accelerometer (which is probably what the article you mention is suggesting). Note that if auto-orientation IS on, the accelerometer axes are also re-oriented. You are also limited on which orientations you can set manually on Android (another OS limitation).