Smooth / rapid view adjustment in response to device orientation
I am disappointed with the current performance of device orientation support in Air 3.5, and am looking for a better way to repond to orientation changes using a native AS (non-flex) Air for mobile.
With stage.autoOrients = true, and using only Event.RESIZE to handle screen updates, the effect is extremely ugly. I will attempt to describe what happens:
- User changes orientation from portrait to landscape
- The image on the screen rotates to match the new orientation but does not scale
- As a result, the image on the screen is now cropped by the bottom of the screen AND the right half of the screen (that is not covered by the width of the previously portrait-oriented image) is now BLANK (ie: white or black)
- After a brief delay, the Event.RESIZE event is triggered
- User code can then read the stage.stageWidth and stage.stageHeight properties and can re-layout accordingly.
A similar experience happens when the user rotates from landscape to portrait.
- The image on the screen rotates to match the new orientation but does not scale
- Now the right side of the image is cropped by the right side of the screen, and the bottom half of the screen (that's not covered by the height of the previously landscape-oriented image) is now BLANK (white or black)
- There is a delay before Event.RESIZE triggers and executes the user layout code.
First of all, I guess I'm confused about stage.autoOrients. When it is set to false, no stage orientation events are dispatched at all. It feels like stage.autoOrients is trying to control two separate behaviours: 1. creating the automatic screen rotation animation when the device is re-oriented and 2. controlling whether StageOrientationEvents are actually dispatched or not.
From the notes:
Note: If the autoOrients property is false, then the stage orientation does not change when a device is rotated. Thus, StageOrientationEvents are only dispatched for device rotation when autoOrients is true.
This is actually pretty bogus, because it doesn't look like there's a good way to short-circuit the slow (and frankly broken-looking) auto-orientation animation.
With stage.autoOrients set to true, you can capture StageOrientationEvent.ORIENTATION_CHANGING and StageOrientationEvent.ORIENTATION_CHANGED. Within an ORIENTATION_CHANGING event you can call event.preventDefault() to essentially abort the animation, while retaining the capture of the event. This looks promising.
Except, that if you do abort the event with event.preventDefault(), the ORIENTATION_CHANGED event does not occur, and for some reason, this causes the framework to not fire the event when the device orients to its ORIENTATION_DEFAULT (typically portrait) orientation. And so you can never capture the landscape-to-portrait orientation change.
What is up with that?
How are you dealing with orientation change and smooth re-layout on mobile for android (I haven't yet tested on iOS)? Do you live with the automatic re-orientation animation, with its truncated display and the delay before you re-layout your view? Is there a funky workaround that allows you to draw stuff off-screen or in some other way make that user experience feel less broken and more like a native app behaves?
