I am having a fairly huge problem. I am hoping this is due to my own stupidity and not a bug of some sort. I have code that needs to know the screen dimensions. I have not found a reliable way to do that. Using production release of Flash Builder 4.5 on iPad 2 and iPhone4/iPod Touch 4 iOS devices. In general my app works great but I can't determine the screen size and orientation at program start time. Let me explain the problems I am having:
On entry into the "init" function, the one called by the ADDED_TO_STAGE event, the values of stage.stageHeight and stage.stageWidth are both 0.
I can query Capabilities.screenResolutionX and Capabilities.screenResolutionY, but they are WRONG. They have the raw X and Y values, but regardless of the orientation. So for example I start in landscape mode by screenResolutionX contains 768 (or whatever) instead of 1024.
I look at the values of stage.width and stage.height and they don’t have valid values.
I have an onResize function setup for EVENT.RESIZE, but it doesn’t get called if the app is started from the device when it is in landscape mode already. If I start the app in portrait mode and then rotate, this does get called.
So my question is what should I query right at the startup of the app to know the real width and height of the app. There must be a way to do this but apparently not using any of the methods above!
By the way, this is on iOS devices. I can’t say how it works on others. I have confirmed these results both by printing out the results and by running it in the debugger.