Copy link to clipboard
Copied
My app supports both orientations adnd I have just noticed a problem if you rotate the app whilst the default.png image is being displayed.
If I launch my app with the device in a particular orientation it works fine
If I rotate the app whilst the default.png image is being displayed, it displays the content in the wrong orientation.
So for example if I launch the app with the device held in portrait mode. The correct default image appears, Whilst this is on screen I rotate to landscape and then the content displays but instead of being the landscape orientation graphics, it is the portrait.
If I then rotate the app again it resolves itself but it is not a very professional start to the app so I would like to fix this.
I have 2 keyframes for my content with the labels "portrait" and "landscape" and use the code
<code>
stage.addEventListener( StageOrientationEvent.ORIENTATION_CHANGING, onOrientationChanging );
function onOrientationChanging( event:StageOrientationEvent ):void {
if(event.afterOrientation == StageOrientation.ROTATED_LEFT || event.afterOrientation == StageOrientation.ROTATED_RIGHT ) {
-- Display Landscape Graphics Layout
}
if(event.afterOrientation == StageOrientation.UPSIDE_DOWN || event.afterOrientation == StageOrientation.DEFAULT ) {
-- Display Portrait Graphics Layout
}
}
I also call the following code on start up
if (stage.orientation == StageOrientation.DEFAULT || stage.orientation == StageOrientation.UPSIDE_DOWN) {
-- Display Portrait Graphics Layout
}
if (stage.orientation == StageOrientation.ROTATED_RIGHT || stage.orientation == StageOrientation.ROTATED_LEFT) {
-- Display Landscape Graphics Layout
}
</code>
I suspect the problem is due to the value of stage.orientation not being available initially but do not know what the solution is to get this info in this situation, Perhaps there is some alternative code I can use initially to determine what orientation graphics should be displayed?
Here are my publishing settings.
Aspect Ratio: Auto
Full Screen checked
Auto Orientation checked
Render Mode auto
Device iPad
Resolution standard
Air 3.4
Flash CS6
Thanks in advance
Copy link to clipboard
Copied
Can this be accessed on app startup?
http://help.adobe.com/en_US/as3/dev/WS901d38e593cd1bac40357fa212caafb9dd0-8000.html
Copy link to clipboard
Copied
I suspect not as on that page it states:
The deviceOrientation is not always available when your application first starts up or when the device is lying flat.
Copy link to clipboard
Copied
AS code within the application is executed once application is done with displaying the launch image. In the application constructor, you can get the correct value of stage.orientation but stage.deviceOrientation might return unknown.