• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ADDED_TO_STAGE When should I use it?

New Here ,
Feb 11, 2011 Feb 11, 2011

Copy link to clipboard

Copied

Hi.

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

Thanks

TOPICS
ActionScript

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Feb 11, 2011 Feb 11, 2011

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.

Votes

Translate

Translate
Guest
Feb 11, 2011 Feb 11, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 11, 2011 Feb 11, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 11, 2011 Feb 11, 2011

Copy link to clipboard

Copied

>>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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 11, 2011 Feb 11, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 11, 2011 Feb 11, 2011

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines