Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

 

/*create a timer that could do something every second 60 times*/

var clockTimer:Timer = new Timer(1000, 60);

/*add an event listerer to the button that will call the startTimer function*/

startButton.addEventListener(MouseEvent.CLICK, startTimer);

/*add event listeners for the timer*/

clockTimer.addEventListener(TimerEvent.TIMER, moveHand);
clockTimer.addEventListener(TimerEvent.TIMER_COMPLETE, endTimer);

/*start timer*/

function startTimer(e:MouseEvent):void
{
clockTimer.start();
trace("timer started");

startButton.visible = false;
}

//move hand
function moveHand(e:TimerEvent):void
{
secondHand.rotation = secondHand.rotation + 6;
trace("Timer cycle expired");
}

//end timer

function endTimer(e:TimerEvent):void
{
trace("timer done");
}