AS3 trouble instantiating Document Class of loaded SWF
Posted
by Marcy Sutton
on Stack Overflow
See other posts from Stack Overflow
or by Marcy Sutton
Published on 2010-05-03T04:43:17Z
Indexed on
2010/05/03
4:48 UTC
Read the original article
Hit count: 284
I am loading one swf into another using the Loader class, but when the child swf finishes loading and is added to the display list, its Document Class is not instantiated. I have a few trace statements should execute when the object is created. When I compile the child SWF on its own, the Document Class runs as expected.
So I'm wondering... how do I associate a child SWF's Document Class with Loader.content
?
// code in parent SWF's Document Class (Preloader)
public function Preloader(){
swfLoader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderDone);
swfLoader.load(new URLRequest("mainmovie.swf"));
}
private function loaderDone(e:Event):void {
// Add Loader.content to new Sprite
mainMovie = Sprite(e.target.content);
mainMovie.alpha = 0;
swfLoader = null;
addChildAt(mainMovie, 0);
mainMovie.addEventListener(Event.ADDED_TO_STAGE, mainMovieAddedListener);
}
// functions in MainMovie.as not ever running,
// even though it is listed as the child SWF's Document Class
Cheers!
© Stack Overflow or respective owner