开发者

air for android - stage.setOrientation deprecated in AIR 2.5 so how do I do it now?

as3 air for android using flash CS5

my problem: testing an AIR app on my droid 2 global (with slide out keyboard) using stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, handleOrientationChange); this is only fired when the i slide the keyboard out and not when I rotate the phone. I have tried this with the auto orientation on and off and with the aspect to portrait and landscape.

actually the auto orientation option does not seem to make a difference on or off.

I need the orientation to change when i rotate the phone. I know i can use the accelerometer to do this but the problem with that is when I click on a textField with the keyboard closed only the vertical keyboard pops up and i need the other one to pop up when holding the phone sidew开发者_开发问答ays.


I have the same problem. Researched a bit and found out about stage.setAspectRatio. It doesn´t do very much for me, but maybe you could figure something out.

stage.setAspectRatio(StageAspectRatio.LANDSCAPE); //LANDSCAPE or PORTRAIT

Let me know if you figure out some more!


I've posted a crossplatform-compatible solution on my blog:

http://digitale-avantgarde.com/orientierungslos/

As you may notice, it's in german, but you can translate it with google!

I'd really appreciate it, if you do comment on my blog ;)

If you're totally lost (and not willing to ask), you can just download the class StageOrientationObserver on the end of the article and go for gold using this code:

import com.digitaleavantgarde.StageOrientationObserver;

var observer = StageOrientationObserver.instance;
observer.addEventListener( StageOrientationEvent.ORIENTATION_CHANGE, onOrientationChange);
function onOrientationChange(evt:StageOrientationEvent):void
    {
        switch (evt.afterOrientation) {
            case StageOrientation.DEFAULT:
                trace("DEFAULT");
            break;
            case StageOrientation.ROTATED_RIGHT:
                    trace("ROTATED_RIGHT");
                    break;
            case StageOrientation.ROTATED_LEFT:
                trace("ROTATED_LEFT");
            break;
            case StageOrientation.UPSIDE_DOWN:
                trace("UPSIDE_DOWN");
            break;
        }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜