Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4579006
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:34:53+00:00 2026-05-21T20:34:53+00:00

I am having a fairly huge problem. I am hoping this is due to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:34:53+00:00Added an answer on May 21, 2026 at 8:34 pm

    I have previously had issues with stageWidth and stageHeight not giving proper values immediately on startup, an easy way to get around this is to wait a frame or two before checking them.

    One option is to delay the initialization of your app, something along the line of this:

    private var _startup_delay:int = 10;
    
    public function Constructor(){
        addEventListener(Event.ENTER_FRAME, handleEnterFrame);
    }
    
    public function handleEnterFrame(e:Event):void{
        _startup_delay--;
       if(_startup_delay <= 0){
           init();
           removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
        }
    }
    

    Another option is to instead dispatch a fake resize event and let your previous rotation code deal with it once the delay has passed:

    public function handleEnterFrame(e:Event):void{
        _startup_delay--;
       if(_startup_delay <= 0){
           stage.dispatchEvent(new Event(Event.RESIZE));
           removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a fairly general problem I am having here, so I figured I
This is a fairly straight forward question but I'm having a problem finding a
Fairly new to Spring, so I'm having some trouble with this. I'm trying to
Having a brain freeze over a fairly trivial problem. If I start with an
I'm fairly certain I'm having memory leaks using KO version 2.0. I have an
I'm fairly new to Zend and am having some difficulties with creating my unit
I am fairly new to xslt (2.0) and am having some trouble with a
I've come across a fairly obscure problem having to do with measuring a document's
I am fairly new to Git, and I am having a problem with doing
I'm fairly new to Java and I've been having some difficulties with Swing. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.