I am working with Flash Professional IDE. Referencing the classes below, if I set the class property of the FLA to testingsub1 (ignoring Main) the code works fine. But if I set the class to Main the code dies at stage.addChild(container); of testing with "TypeError: Error #1009: Cannot access a property or method of a null object reference.".
This goes against my understanding that the stage is global and always available to have display objects added directly. Any insight and solution?
package {
//import com.idtlw.iso.utils.Const;
import flash.display.*;
public class testingsub1 extends testing {
public function testingsub1() {
trace("initializing testing sub 1");
var container:Sprite=new Sprite();
var test1:Sprite=new Sprite();
container.addChild(test1);
}
}
}
package {
import flash.display.*;
public class testing extends Sprite {
public function testing() {
trace("initializing testing");
var container:Sprite=new Sprite();
var test1:testreg1=new testreg1();
container.addChild(test1);
stage.addChild(container);
}
}
}
package
{
import flash.display.*;
public class Main extends Sprite
{
public function Main ()
{
var test1:Sprite=new Sprite();
stage.addChild(test1);
var tester:testingsub1=new testingsub1();
}
}
}
stageis not globally accessible. Thestageproperty of a DisplayObject is null unless it is attached to the display list hierarchy of the stage. - prototypicalstagedirectly. We are talking about components that could be nested in many possible situation; a component shouldn’t be able to add another component to the stage directly. - poke