jeangj
06-18-2008, 07:09 PM
Hi peeps
I'm still working on my spaceship shootergame Class and I've got an error which I coulnd't get rid off:-(
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at UfoGame/moveBullet()
On hitTestObject I want to refer to a textfield on frame 3 in the target ufo01_mc tween. (I add the ufo01_mc on the stage via AS3)
The explosion on the ufo01_mc starts on frame 3, where i set a dynamic textfield called pt_txt (show points).
When I set the textfield on frame 1 of the tween it works. However, that's not what it should be. So how can I refer to the textfield in frame 3, since I already set the ufo01_mc.gotoAndPlay(3)???
public function moveBullet(e:Event):void{
// if ufo is on stage, moveBullet, else stop bullet
if(ufo01_mc !=null) {
e.target.y -= 20;
if(e.target.hitTestObject(ufo01_mc)){
ufo01_mc.gotoAndPlay(3);
ufo01_mc.pt_txt.text = types[count].points;
//ufo01_mc.pt_txt.text = "dkj";
points = points + types[count].points;
countPt();
e.target.removeEventListener(Event.ENTER_FRAME, moveBullet);
removeChild(MovieClip(e.target));
}
}else{//no bullet
bullet.x = -400;
}
I'm still working on my spaceship shootergame Class and I've got an error which I coulnd't get rid off:-(
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at UfoGame/moveBullet()
On hitTestObject I want to refer to a textfield on frame 3 in the target ufo01_mc tween. (I add the ufo01_mc on the stage via AS3)
The explosion on the ufo01_mc starts on frame 3, where i set a dynamic textfield called pt_txt (show points).
When I set the textfield on frame 1 of the tween it works. However, that's not what it should be. So how can I refer to the textfield in frame 3, since I already set the ufo01_mc.gotoAndPlay(3)???
public function moveBullet(e:Event):void{
// if ufo is on stage, moveBullet, else stop bullet
if(ufo01_mc !=null) {
e.target.y -= 20;
if(e.target.hitTestObject(ufo01_mc)){
ufo01_mc.gotoAndPlay(3);
ufo01_mc.pt_txt.text = types[count].points;
//ufo01_mc.pt_txt.text = "dkj";
points = points + types[count].points;
countPt();
e.target.removeEventListener(Event.ENTER_FRAME, moveBullet);
removeChild(MovieClip(e.target));
}
}else{//no bullet
bullet.x = -400;
}