What am i doing wrong? The program is meant to move a picture of a plane over the screen. The speed of the plane is increasing over time. The stage has a timer that runs the function 10 times per second
private function myTimer(e) {
var speed:int = 0;
plane.x = plane.x + speed
speed = speed + 10
}
You are defining the
speedvariable inside the function, this causes it to be initialized to 0 on every call, and since you only add to the speed after changing the x of the plane it never moves.If you move the
var speed:int = 0;definition outside of the function the changes will not be overwritten on each call.