The answer above did not help me, because on iOS the preventDefault function no longer works.
For those who just don't have luck yet ... That's what I did.
I wanted:
IPad and all Android Tablet devices to be able to portrait or landscape and automatically rotate in any direction
Iphones, Ipods and All Small Screen Devices will be forced to move around the landscape (or maybe in your case you need a forced portrait).
I did:
In my -app.xml:
<aspectRatio>any</aspectRatio> <autoOrients>true</autoOrients>
In Actioncript:
var screenDPI:Number = Capabilities.screenDPI; var resolutionX:Number = Capabilities.screenResolutionX; var resolutionY:Number = Capabilities.screenResolutionY; var numDiagonalDistance:Number = Math.round(Math.sqrt((resolutionX*resolutionX)+(resolutionY*resolutionY))); var numDiagonalInches:Number = numDiagonalDistance/screenDPI; if(numDiagonalInches<6){ MainData.SMALL_DEVICE=true; }else{ MainData.SMALL_DEVICE=false; } if(MainData.SMALL_DEVICE){ this.stage.setAspectRatio(StageAspectRatio.LANDSCAPE); }
Although I think you could easily put StageAspectRatio.PORTRAIT or even use the reverse logic only for logical ipads or something else. Good luck
EDITED: I am really editing this because even this method still has problems. You will get a landscape, but itβs not always a landscape focused on how you hold the device ...
EDIT AGAIN (2-27-2014): It turns out that if I turned on -swf version 23 (now with AIR 4.0), this problem is finally resolved.
Ryan source share