开发者

AS3 and the loader class

I write here, because after looking for a solution, I could not resolve my error...

var test:MovieClip;

var sign:Loader = new Loader();  
sign.contentLoaderInfo.addEventListener(Event.COMPLETE, completSIGN);  
sign.load(new URLRequest("http://files.zebest-3000.com/278374/3011/3011.swf"));  

function completSIGN(e:Event):void  
{  
test = MovieClip(e.target.content);  
addChild(test);  
}

This is the error:

TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul. at Main::StateManager()

So, the movie (some videos work perfectly and others not) does not want to load in my container ; it seems there is a problem in the mapp开发者_如何学运维ing... and can't modify the distant movie.

  • Is there an other method of loading a movie inside one other (I have try also to load with bytearray, but it's the same)?
  • Can we catch this error and relocate the instance to help him to find the correct way?


Based on your comment I assume that StateManager() is called from the constructor of the document class of the remote SWF and it tries to access stage using something like this.stage or this.root.stage. Now, it'll work without any issues when run as a standalone SWF because the stage property would've been set by the time document class's constructor is called. When loaded remotely stage is set only after you add it in the complete handler.

I'm not sure about this, but try calling addChild(sign); before you call sign.load - you can remove those two lines from the completeSign method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜