PDA

View Full Version : create a 2minute timer


louise88
02-25-2008, 08:03 PM
Hi,

I have tried looking for tutorials on timers but am a bit confused. How would i create a 2 minute timer that counts down. The timer would begin on the startGame function?

Any help would be appreciated!

rrh
02-26-2008, 04:53 PM
AS2?

http://www.dreamincode.net/code/snippet122.htm

Found by googling actionscript timer

sasuke
03-10-2008, 05:31 AM
http://www.flashcomponents.net/author/mohdfaisalbinkhalid.html

Durnus
03-10-2008, 07:08 PM
This is really simple to do. Depends on the timer you want to use though. Are you asking for graphical representation of the time, or just something that executes a function after X seconds?

AS2:

function toExecute()
{}
setInterval( 1000 /*This is any number of milliseconds, 1000 in one second.*/, toExecute /*The function to execute after the number of milliseconds.*/);


AS3:

var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, functionToExecute);
function functionToExecute(e:Event)
{}
//Same idea applies here, 1000 is in milliseconds, and if you are using AS3 you should know AS3 well enough to get this code.


All I can tell you is this: Do NOT buy some sort of device to keep time unless it is exactly what you wanted and you can't get help. You can get your help here for free, and actually I'll do it for you if you want to once I get to my home computer. (At school right now.)

Good luck. :D