My timer isn't stopping and I can't figure out why. It's probably something really simple, but I cant get it.
Any ideas. It traces 5 (the MaxTime var) and then every time it runs the increment function it traces timer, but timer doesn't stop at 5 like I want it to. It keeps going on forever. So im guessing the clearInterval is being used wrong on my part or something D:
Heres my code, all on the first frame
StartTimer(5)
function StartTimer(MaxTime:Number):Void {
_root.timer = 0;
trace(MaxTime)
TimerInterval = setInterval(Increment, 1000);
if (_root.timer == MaxTime) {
clearInterval(TimerInterval);
_root.timer = 0;
}
}
function Increment():Void {
_root.timer++;
trace(_root.timer);
}