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 trying to load an external swf that uses a document class, it had an access error to the stage
object. To be clearer, a document class is configured in the swf publication that will be loaded:
Inside the Main.as
, have the class for the access code to the stage:
package {
import flash.display.MovieClip;
public class Main extends MovieClip {
public function Main() {
// access 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 to solve this problem?