The answer above did not work for me, because on iOS the preventDefault no longer works.
For anyone who just still isn't having good luck... Here's what I did.
I wanted:
Ipad & All Android Tablet devices to be able to Portrait or Landscape and auto-rotate in any direction
Iphones, Ipods, & All Small Screen Devices to be forced Landscape (or maybe in your case you want forced portrait).
I Did:
IN my -app.xml:
<aspectRatio>any</aspectRatio>
<autoOrients>true</autoOrients>
In Actionscript:
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);
}
Though I guess you could easily put StageAspectRatio.PORTRAIT or even use the reverse logic to logic ipads only or something. Good Luck!
EDITED: I'm actually editing this because even this method still has problems. You'll get landscape but its not always the landscape oriented to how you're holding the device...
EDITED AGAIN (2-27-2014): Turns out if I included -swf-version 23 (now with AIR 4.0) this problem is finally solved.