Jump to content
Search Community

Accessing .stage from a loaded swf

giuggio test
Moderator Tag

Recommended Posts

LoaderMax is exactly what I needed... Thanks!

 

Anyway, how is it possible to access the stage properties from a loaded swf? Strange, I get the error #1009: Cannot access a property or method of a null object reference.

There must be a way...

 

Greetings!

Link to comment
Share on other sites

When a swf is first loaded it isn't in the display list yet so its "stage" property will be null. What I always do is put conditional logic in my child swf, kinda like:

 

if (this.stage == null) {
   this.addEventListener(Event.ADDED_TO_STAGE, init);
} else {
   init(null);
}

 

init() is obviously where all my stage-dependent code runs. And don't forget to remove the ADDED_TO_STAGE listener there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...