Copy link to clipboard
Copied
Hi,
I am using a Timer function to repeat a function however the function only begins (and repeats) after the period set eg. 5 seconds not immediately.
Here is an example of the code:
var myTimer:Timer = new Timer(2000,8);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener (e:TimerEvent):void{
trace("Timer is Triggered");
}
myTimer.start();
Is there any way to make the function start immediately then repeat?
Thanks
Chris
Copy link to clipboard
Copied
after timer.start()
add
myTimer.dispatchEvent(new TimerEvent(TimerEvent.TIMER));
this will trigger your function immediately
Copy link to clipboard
Copied
That's really useful.
Thanks!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now