Idle timer

hiya-

I need to create an idle timer. I know that the timer would start on load and reset when a user were to rollover or release a btn but how do i code the actual timer?

I found possible explanations on the web but they would need to be modified to do what I need. Unfortunately, I don’t understand the concept enough to accurately modify them.

Please Help ;o)

Hi- you might want to start with the ‘setInterval’ and ‘clearInterval’ functions in flash. These functions work by calling a function at the specified time interval that you choose. To create a timer that triggers evey second:

myInterval = setInterval(callback1, 1000);

function callback1()
{
// do something every second
}

For your rollover:

myButton.onRollover = function()
{
// clear and restart the timer
clearInterval(myInterval);
myInterval = setInterval(callback1, 1000);

}

ahhh. thank you i’ll see if this does the trick. Here’s something for jollies. don’t know if it works yet…It is far more cumbersome than the code above.

[FONT=Arial] function doCountdown(countAmount){[/FONT]
[FONT=Arial]var startTime=getTimer();[/FONT]
[FONT=Arial]var elapsed=0;[/FONT]
[FONT=Arial]this.onEnterFrame=function(){[/FONT]
[FONT=Arial]elapsed=getTimer() – startTime;[/FONT]
[FONT=Arial]if(elapsed>countAmount*1000){[/FONT]
[FONT=Arial]var elapsed=0;[/FONT]
[FONT=Arial]some_mc.gotoAndPlay(“framelabel");[/FONT]
[FONT=Arial]}[/FONT]
[FONT=Arial]}[/FONT]
[FONT=Arial]}[/FONT]
[FONT=Arial] [/FONT]
[FONT=Arial]doCountDown(60);[/FONT]