The code below gives you an example of the wonderful timer class, before this timers were a total pain in ActionScript 2, this new class gives us all the functionality we always had to code around before.
———– code sample
var myTimer:Timer = new Timer(5000,1);
myTimer.addEventListener(TimerEvent.Timer, timerFunction);
function timerFunction(event:TimerEvent):void
{
trace(“Timer function executed”);
}
myTimer.start();
———– end code sample
We first create an instance of the Timer class and tell it we want it to fire every 5 seconds (5000) and to do it only 1 time. Then we create an EventListener and tell it to call our method/function called timerFunction which simply traces some text to the output window. Then finally we just need to tell our timer instance to start. The timer instance will stop after it has executed the specified amount of times (in this case once).
2 comments:
This post is from my blog?
http://grfxguru.wordpress.com
Well yea, since it links directly to you.
Post a Comment