Skip navigation
Currently Being Moderated

ADDED_TO_STAGE When should I use it?

Feb 11, 2011 11:19 AM

Hi.

I´d like to know in which cases is better or not to use ADDED_TO_STAGE event.

Thanks

 
Replies
  • Currently Being Moderated
    Feb 11, 2011 11:49 AM   in reply to marcelozepgames

    Not always needed, of course, but if your movie is being loaded by another movie and you try and reference stage in the constructor it won't work - as the constructor will run before your file is completely loaded. In that case you can use added_to_stage.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2011 12:18 PM   in reply to marcelozepgames

    The display object is "mostly" ready when the constructor code is hit. But there are times when it is safer to add an event listener for "Added to Stage" and in the handler everything will be initialized. For example, I have found it better to fetch get Flash Vars from the loaderInfo after this event fires.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2011 12:32 PM   in reply to Randy Troppmann

    >>For example, I have found it better to fetch get Flash Vars from the loaderInfo after this event fires.

     

    FlashVars are not affected - they are available regardless. Pretty much the only times added_to_stage is needed is when you're trying to access stage properties in the constructor.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2011 1:16 PM   in reply to dmeN

    Hmmm ... that has proven problematic for me in the past so I don't trust it. I always fetch for FlashVars in this event handler. I think ADDED_TO_STAGE is a good fallback to solve some initialization race conditions that may creep up.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2011 2:07 PM   in reply to Randy Troppmann

    I agree that added_to_stage is a problem solver and I use it frequently. Many times I use it just in case the swf I'm building _might_ be loaded by another. I've just not had a time, that I can recall, when loaderInfo wasn't available straight away.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points