Problems with stopping timer

Can anyone explain to me, why stopping the timer after 50 runs doesn’t work in the following code:


var timer:Timer = new Timer(50);
timer.addEventListener(TimerEvent.TIMER, flopActions);
timer.start();

var a:Number = 0;
				
function flopActions(evt:TimerEvent):void
{
   a++;
   trace(a); // 1, 2, 3, 4, 5, 6, ...
   if(a == 50)
   {
       trace("please stop ;-)" ); // output: please stop ;-)
       evt.target.stop();         // doesn't work
       timer.stop()	                // doesn't work
   }
}

That code works for me.

you don’t need to increment a variable, the timer event returns the amount of times its looped.

[QUOTE=Krilnon;2358584]That code works for me.[/QUOTE]

ditto

you can also set to have it only run a certain amount of times

var timer:Timer = new Timer(50,50); // 50 milliseconds, 50 times