Skip to main content
Inspiring
April 29, 2006
Question

inactivity times

  • April 29, 2006
  • 3 replies
  • 215 views
I would like to build a timer that counts down and triggers a timeline
action once it gets to 0. Everytime the user clicks on anything inside
that file, the timer would reset itself and start over. So as long as
there is activity, it would not get to the end, but if the user would
abandon the file, it would eventually reset itself.

So I guess I am looking for two pieces of code. One the timer code and
second something like a listener for activity or a release inside the file.

Thank you for any help/suggestins with this!

Brian
This topic has been closed for replies.

3 replies

kglad
Community Expert
Community Expert
April 30, 2006
see your other thread.
Inspiring
April 30, 2006
kglad, thank you for your help! I put the AS you gave me in place and it
seems to work, except for it does not seem to reset the timer when I
move the mouse. So it times and does it's thing if time runs out, but it
does not reset in case you do the mouse move.

I modified the code you gave me a little bit, this is what I have at the
moment. Any ideas why this is not working?

Thank you so much for the help!
Brian



startTime = getTimer();
checkActivityI = setInterval(checkActivityF, 5000);
var mouseListener bject = new Object();
mouseListener.onMouseMove = function(){
startTime = getTimer();
trace("mouse was moved");
checkActivityI();
};
Mouse.addListener(mouseListener);

function checkActivityF() {
secondsOfInactivity = Math.round((getTimer()-startTime)/1000);
timeUntilTrigger = timeLimit-secondsOfInactivity;
if (secondsOfInactivity>=timeLimit) {
// inactive trigger - do something
trace("testing the timer");
gotoAndPlay("close");
clearInterval(checkActivityI);
}
}
kglad
Community Expert
Community Expert
April 29, 2006
define timeLimit and try: