# Combining Mouse.addListener and getTimer

**URL:** https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568
**Category:** Uncategorized
**Created:** [August 4, 2003, 5:42am UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568 "2003-08-04T05:42:02Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![gepo](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@gepo](https://forum.kirupa.com/u/gepo)
#### Post date: [August 4, 2003, 5:42am UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/1 "2003-08-04T05:42:02Z")

</div>

I need to get my movie to check if the user has click anywhere on the interface (doesn’t matter were), if there’s not click after 60second, I need to send the movie back to frame1.

I know is a combination of addListener(Mouse), onMouseMove  
and getTimer. but I’m not very good at action script yet to combine the three. Any code sample and tutorials are more then appreciated.

THANKS  
gepo

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 4, 2003, 10:30am UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/2 "2003-08-04T10:30:44Z")

</div>

what happens if he does click? this should basically work:

```auto
var timerID;
function stopTimer() {
  clearInterval(timerID);
}
var mouseListener = { onMouseDown: stopTimer };
Mouse.addListener(mouseListener);
function gotoFrameOne() {
  _root.gotoAndStop(1);
}
timerID = setInterval(gotoFrameOne,60000);

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 4, 2003, 6:58pm UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/3 "2003-08-04T18:58:02Z")

</div>

yes it’s working , Almost perfect  
"what happens if he does click?.."  
I need a way to tell timerID that if something is click to set itself back to 0 and start cheking the time again.

can you help me with that??  
much thanks

gepo

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 4, 2003, 7:19pm UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/4 "2003-08-04T19:19:13Z")

</div>

i assumed thats what you want… try this:

```auto
var timerID;
function startTimer() {
  timerID = setInterval(gotoFrameOne,60000);
}
function resetTimer() {
  clearInterval(timerID);
  startTimer();
}
var mouseListener = { onMouseDown: resetTimer };
Mouse.addListener(mouseListener);
function gotoFrameOne() {
  _root.gotoAndStop(1);
}
startTimer();

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 4, 2003, 7:45pm UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/5 "2003-08-04T19:45:05Z")

</div>

thanks brainy, almost perfect again  
there’s alittle glich that I can seem to fiind. It looks like sometime [COLOR=red]var timerID;[/COLOR] ;it reset istself and sometime it doesn’t.  
Could you take a look at my example??  
much thanks

gepo

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2003, 3:37pm UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/6 "2003-08-06T15:37:36Z")

</div>

Can’t anybody help me clean this uP???  
thanks  
gepo

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2003, 4:30pm UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/7 "2003-08-06T16:30:17Z")

</div>

[AS]function startTimer() {  
start = getTimer()/1000;  
}  
\_root.onEnterFrame = function() {  
elapsedTime = Math.floor(getTimer()/1000-start);  
(elapsedTime == 60) ? \_root.gotoAndStop(1) : trace(elapsedTime);  
};  
var mouseListener = new Object();  
mouseListener.onMouseDown = startTimer;  
Mouse.addListener(mouseListener);  
startTimer();[/AS]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2003, 5:32pm UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/8 "2003-08-06T17:32:03Z")

</div>

aaahhhhhaaaaaa perfect  
obrigado Claudio,  
it works perfectly  
gepo

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2003, 5:33pm UTC](https://forum.kirupa.com/t/combining-mouse-addlistener-and-gettimer/27568/9 "2003-08-06T17:33:50Z")

</div>

De nada Gepo (welcome)  
😉
