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
Highlighted
Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10
My Carrier: Telus
Accepted Solution

Switching from landscape to portrait mode, what do I do next?

Hello everyone. I setup the accelerometer in my app, setup the listeners, created a 'portrait' state. what's the call to change state in my _accelerometer.onUpdate()?

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Switching from landscape to portrait mode, what do I do next?

If you're just trying to have your app support the landscape and portrait orientations, I wouldn't bother using the accelerometer. 

 

Either listen for the StageOrientationEvent.ORIENTATION_CHANGE event, or as I am in my current app just monitor Event.RESIZE and don't worry about "landscape" versus "portrait" but instead just respond to the actual width and height values.

 

I know the Tablet OS developer guide stuff shows an example using the accelerometer, but I have to say it mystifies me why they'd bother suggesting that approach.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10
My Carrier: Telus

Re: Switching from landscape to portrait mode, what do I do next?

I didn't even read about the accelerometer approach, I just assumed, but you know what they say about people that assume Smiley Wink Your approach sounds much better. I created 2 states,  onefor landscape one for portrait already, so in the StageOrientationEvent function can I switch states? If so, how?

Developer
Posts: 442
Registered: ‎08-02-2010
My Device: Z10
My Carrier: Telus

Re: Switching from landscape to portrait mode, what do I do next?

Got it.