I am attempting to make a class that handles the building in a game, but I can’t get the object to come on stage. I can get everything to work if I am on the timeline, just not from this class.
I’ve been getting this:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at build$/newBuild()[/Users/student/Desktop/attack/build.as:19]
I attempted to see if my building variable was null so i did a trace…
trace (building);
and got:
[object base]
package {
import flash.display.Sprite;
import flash.display.Stage;
import base;
public class build {
public static var theStage:Stage;
public static function newBuild():void
{
var building:base = new base();
trace(building);
building.x = 250;
building.y = 250;
theStage.addChild(building);
}
}
}
This class is being called from the timeline with:
build.newBuild();
Thanks for any help! =]