So I’m trying to make a circle that moves left and right and creates a bullet that moves up. I have two classes, the circle and the bullet. When I try to run the code, I get: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Bullet/::enterFrameEvents()
here’s my code for the Bullet Class that is created:
package {
import flash.display.*;
import flash.events.*;
import Character;
public class Bullet extends MovieClip {
private var bulletSpeed:Number = 10;
public function Bullet(){
addEventListener(Event.ADDED, beginClass);
addEventListener(Event.ENTER_FRAME, enterFrameEvents);
}
private function beginClass(event:Event):void{
this.x = 200;
this.y = 30;
}
private function enterFrameEvents(event:Event):void{
this.y += bulletSpeed;
if (this.y >= 400){
this.parent.removeChild(this);
}
}
}
}
also, I know the bullet is always created in the same spot. I don’t know how to do that yet. Thanks