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
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.
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.
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.
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.
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.
Copy link to clipboard
Copied
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.