I have a pretty big problem. I hope this is due to my own stupidity, not some kind of mistake. I have a code that needs to know screen sizes. I have not found a reliable way to do this. Using the Flash Builder 4.5 product release on iPad 2 and iPhone4 / iPod Touch 4 iOS devices. In general, my application works fine, but I can not determine the screen size and orientation during the start of the program. Let me explain the problems that I'm having:
When you enter the init function called by the ADDED_TO_STAGE event, the values โโof stage.stageHeight and stage.stageWidth are 0.
I can request Capabilities.screenResolutionX and Capabilities.screenResolutionY, but they are WRONG. They have initial values โโof X and Y, but regardless of orientation. So, for example, I run in landscape mode screenResolutionX contains 768 (or something else) instead of 1024.
I am looking at the stage.width and stage.height values โโand they do not have valid values.
I have a function onResize function for EVENT.RESIZE, but it is not called if the application starts from the device when it is already in landscape mode. If I launch the application in portrait mode and then rotate, it causes a call.
So my question is what should I request right at application launch to find out the real width and height of the application. There must be a way to do this, but apparently don't use any of the above methods!
By the way, this is on iOS devices. I canโt say how it works on others. I confirmed these results by printing the results and running them in the debugger.
source share