I trying to learn and follow some tutorials about classes and stuff like that. If you look att my code I have posted a object called “FallingObject” falls every third second in the speed of “y += 10;”
Now here is my problem.
I want my falling object to increase the speed every 20 second. How do I do that?
ACTIONSCRIPT 3
var TimerFallingObject:Timer = new Timer(3000);
TimerFallingObject.addEventListener(TimerEvent.TIMER, OnStartFallingObject);
TimerFallingObject.start();
function OnStartFallingObject(e:Event){
var af:Sprite = new FallingObject();
af.x= Math.random()*640;
addChild(af);
}
THE CLASS OF “FALLINGOBJECT”:
package {
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.text.TextField;
public class FallingObject extends Sprite {
private var core:Object;
var speedY:Number = 0;
public function FallingObject() {
addEventListener(Event.ADDED_TO_STAGE,onadd);
}
private function onadd(e:Event) {
core=MovieClip(root);
addEventListener(Event.ENTER_FRAME,loop);
}
private function loop(e:Event) {
y += 10;
}
public function removeListeners():void {
removeEventListener(Event.ENTER_FRAME, loop);
}
}
}