I have just updated from AIR 3.6 to AIR 3.9 and have encoutered some unexpected behavior that is giving me grief when attempting to test on the Desktop.
I've been using the following code to set the appropriate screen resolution for my iOS devices for the last couple of years without any issues. However now after updating from Air 3.6 to Air 3.9 under FB4.6, when the onScreenResize() event fires the values of stage.stageWidth & stage.stageHeight just returns the values that I've specified in the following statement (500, 375), rather than the dimensions for the device that I have selected in FB's "Debug Configurations":
[SWF(backgroundColor="#000000", frameRate="30", width="500", height="375")]
This results in the window size and menu layouts for my app not getting setup correctly, which makes it very difficult to test on the desktop. Under Air 3.6 when onScreenResize() gets called stage.stageWidth & stage.stageHeight return the device dimensions properly. This code still seems to work properly when run on an iOS device, just not on the desktop. Does anyone know why stage.stageWidth & stage.stageHeight no longer return the values that they did under Air 3.6 (and how I can fix/work around this issue)?
Some of the code has been removed to improve readability.
[SWF(backgroundColor="#000000", frameRate="30", width="500", height="375")]
publicfunction MyApp()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_BORDER; // StageScaleMode.EXACT_FIT;
stage.scaleMode = StageScaleMode.NO_SCALE;
addEventListener(Event.ADDED, initializeApp, false, 0, true);
}
privatefunction initializeApp(event:Event):void
{
removeEventListener(Event.ADDED, initializeApp);
stage.addEventListener(Event.RESIZE, onScreenResize, false, 0, true);
}
privatefunction onScreenResize(event:Event):void
{
if ( stage.stageWidth == 500 && stage.stageHeight == 375 )
{
// This is an initial default size event that we don't care about.
// Seems like there should be a less hacky way to avoid this situation.
return;
}
// Now that we know the device dimensions, create menu layouts and start the app.
// This no longer gets called as stageWidth/Height are 500/375 above and the function exits.
setDeviceDimensionsAndStartApp();
}
Thanks.