Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I repeat a function that starts immediately?

Guest
Jan 17, 2013 Jan 17, 2013

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

TOPICS
ActionScript
399
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 17, 2013 Jan 17, 2013

after timer.start()

add

myTimer.dispatchEvent(new TimerEvent(TimerEvent.TIMER));

this will trigger your function immediately

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 17, 2013 Jan 17, 2013
LATEST

That's really useful.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines