Timers
One useful thing to do while programming is have a timer that fires every so often to repeat a specific action such as a picture fade. You create and use a timer thus:
//Imports the appropriate library files
import flash.utils.Timer;
import flash.events.TimerEvent;
//Create a timer that will fire every 1000 milliseconds or every second
var timer:Timer = new Timer(1000);
//Add a listener that gets called every second when the timer fires
timer.addEventListener(TimerEvent.TIMER, handleTimer);
//Start the timer
timer.start();
//The handler that runs every second
function handleTimer(event:TimerEvent):void
{
//Do whatever you want to do
trace("timer");
}

Recent Comments