Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
LoganSix
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

mxml and stage orientation

If you have been struggling to determine the stage orientation when using the mxml scripting on your application, I stumbled across the solution today.

 

In your initialization function, add a even listener to the systemManager.stage (not stage or this.stage).

 

private function init():void {

systemManager.stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, onOrientationChanging );

}

 And then do your check for orientation change

private function onOrientationChanging( event:StageOrientationEvent ):void {
                if(event.afterOrientation == StageOrientation.UPSIDE_DOWN || event.afterOrientation == StageOrientation.DEFAULT ) {
                   // set landscape stage                  
                } else {
                   // set portrait stage
                }
            }

 

This has been driving me nuts for days.  The accelerometer didn't work the way it should, but this does.  And you don't get the null object instance issue.

 

 

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Please use plain text.