im new to as3 and am working on a little game and have run into some trouble. basicly im trying to set a bitmap to follow an object i have.
heres some code…
override public function paint():void{
super.paint();
if(imageLoaded=false){
trace("loading image...");
loadImage();
imageLoaded=true;
trace("image loaded.");
}
if(imageLoaded=true){
mBit.x = super.px;
mBit.y = super.py;
}
}
public function loadImage():void{
mData = new BitmapData(game._loader.height,game._loader.width,true,0xffffff);
mBit = new Bitmap(mData);
mData.draw(game._loader);
game.addChild(mBit);
}
all the stuff in the loadImage() used to be where loadImage is called and it would run but would draw the image over and over leaving a trail so i moved it so it would only draw once but now it wont even work, tells me “Error #1009: Cannot access a property or method of a null object reference.” which reffers to “mBit.x = super.px;”.
any help?