Flex Tip: Error accessing the stage when the app first loads

Long story short use the applicationComplete event.

This is something I struggled with for a while. I don’t use a mouse much and like to code keyboard shortcuts into the applications I build. My code initially looked like this:



Tags: , , ,

4 responses to “Flex Tip: Error accessing the stage when the app first loads”

  1. Dov Goldberg says :

    Instead of adding the event listner to the stage object and using the callLater add it to the systemManager object:
    systemManager.addEventListener(_____, _______);

    and get rid of the callLater.

    I hope this works as well!

    Dov

    • Hillel says :

      Thanks for the advice, I generally find that when I’m using the callLater it’s a workaround for something I’m doing wrong. Could you give the file name/line number you’re referring to though, I’m having trouble finding it.

  2. Dov Goldberg says :

    Line 12 in the first code box above. Where you add the eventListener. add it to the systemManager object instead of the stage object.

  3. Dov Goldberg says :

    This site will give a clearer idea of what the systemManger object is:
    http://livedocs.adobe.com/flex/3/langref/mx/managers/SystemManager.html

    It basically is like the stage object in Flash. systemManger is what you should use when writing code in Flex. Are you coming from a Flash background?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: