user1798740
user1798740

Reputation: 29

AS3: Cannot access a property or method of a null object reference at $iinit while loading external swf

I have two swfs, that works perfect separately, but when i try to load one to other, it shows me "Cannot access a property or method of a null object reference at Creator$iinit".

First SWF is login screen, second is register screen. I load them in this way:

var requestA:URLRequest = new URLRequest("Creator.swf");
var loader:Loader = new Loader();
loader.load(requestA);
addChild(loader);

I have no idea whats wrong. Please, help.

Upvotes: 0

Views: 892

Answers (1)

Gone3d
Gone3d

Reputation: 1189

Most likely you're trying to access something that is not available immediately on load and init - you'll need to add some code in the Creator.swf like:

// Somewhere in the first lines of code 
addEventListener(Event.ADDED_TO_STAGE, this.ready);

function ready(e:Event) {
    removeEventListener(Event.ADDED_TO_STAGE, this.ready);

    // ** Do other initialization stuff here

}

What's happening is that you're trying to access the stage or objects before things are ready to accept them.

Upvotes: 1

Related Questions