In your Main.as
, you have added the listener to the stage, not your timer. This line:
stage.addEventListener("tickTack", ontickTack);
should be like this:
_timer.addEventListener("tickTack", ontickTack);
But ActionScript already has a Timer
class that looks like it has all the functionality you need. No need to reinvent the wheel. Take a look at the documentation for the Timer class.
In your main you could just say:
var count:int = 10; // the number of times the timer will repeat.
_timer = new Timer(1000, count); // Creates timer of one second, with repeat.
_timer.addEventListener(TimerEvent.TIMER, handleTimerTimer);
_timer.addEventListener(TimerEvent.TIMER_COMPLETE, handleTimerTimerComplete);
Then just add your handler methods. You don't need to use both. Often the TIMER event is enough. Something like this:
private function handleTimerTimerComplete(e:TimerEvent):void
{
// Fires each time the timer reaches the interval.
}
private function handleTimerTimer(e:TimerEvent):void
{
// Fired when all repeat have finished.
}