Your Ad Here

Timers in Actionscript 3

I'm writing this tutorial for someone who posted a comment on Basic Actionscript 3 Game Part 1 called sstng so if you would like to know how to do a certain thing in a language then feel free to post a comment and ask.

Timers in Actionscript 3 are really simple and easy to use and understand.

Sstng wanted to know how to create a timer that is triggered after 100 seconds.

Here is the code we would use to do this.


//set the time you want in milliseconds.
var myTimer:Timer = new Timer(100000, 1); //100 seconds
myTimer.addEventListener(TimerEvent.TIMER, theAction); //when the timer hits 100 seconds it will run the Action
myTimer.start() //start the timer

function theAction(event:TimerEvent) :void {
trace("Timer Triggered"); //output a message so you know its working
}

I hope this has helped.

3 Responses to “Timers in Actionscript 3”

  1. Recent Links Tagged With "actionscript3" - JabberTags Says:

    [...] public links >> actionscript3 Timers in Actionscript 3 Saved by lroosma63 on Tue 09-9-2008 Blender 2.46のArmature(アーマチュア)... Saved by [...]

  2. codebounce.com Says:

    Thanks. Useful code. It does help :)

    Suggestion:
    Noticed you do not have a contact form in this site.
    I tried to contact you and this was the only way to let you know.

    Best
    Tom

  3. Flash Tutorials Says:

    People mostly get confused in using action script but your tutorial shows that it is not to hard to understand.

Leave a Reply

Your Ad Here