How can an external swf access the stage within the document class?

1

I have a main swf that loads other swfs. Everything works correctly with the code below that is inside the main swf ( sketch ):

var loader:Loader = new Loader();
stage.addChild(loader);
loader.load(new URLRequest('external.swf'));

However, when attempting to load an external swf using a document class , an access error to the stage object began to occur. To make it clearer, the document class is configured in the swf publication that will be loaded:

Within the class Main.as there is the stage access code:

package {
    import flash.display.MovieClip;
    public class Main extends MovieClip {
        public function Main() {
            // tentar acessar o stage:
            trace(stage);
            trace(stage.stageWidth);
        }
    }
}

When the main swf tries to load the external swf, the error occurs:

null
TypeError: Error #1009: Cannot access a property or method of a null object reference.

How do I solve this problem?

    
asked by anonymous 06.12.2016 / 15:37

0 answers