# Timing movie clips

**URL:** <https://forum.kirupa.com/t/timing-movie-clips/63109>\
**Category:** Uncategorized\
**Created:** [September 3, 2004, 12:33am UTC](https://forum.kirupa.com/t/timing-movie-clips/63109 "2004-09-03T00:33:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![zerosignal0](https://avatars.discourse-cdn.com/v4/letter/z/8edcca/32.png) [@zerosignal0](https://forum.kirupa.com/u/zerosignal0)\
**Post date:** [September 3, 2004, 12:33am UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/1 "2004-09-03T00:33:28Z")

</div>

Hello,  
Ok I am making a menu that opens up on mouse rollover and I cant really figure out how to make the script to close it after a few seconds if they havent moved the mouse inside of it… I know that last sentence might not make alot of sense but Im basically just trying to make the menu move back to its original spot if the mouse hasnt rolled over it in 5 seconds. Can anyone point me in the right direction?  
thanks

---

<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:** [September 3, 2004, 6:58pm UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/2 "2004-09-03T18:58:00Z")

</div>

so no one knows what Im talking about?

---

<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:** [September 3, 2004, 8:05pm UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/3 "2004-09-03T20:05:20Z")

</div>

> [@zerosignal0](#):
>
> so no one knows what Im talking about?

try something like this

function getoldX() {  
oldX = \_xmouse;  
clearInterval(Int1);  
}  
function checkMouse() {  
if (Math.abs(\_xmouse-oldX\<5) && Math.abs(\_ymouse-oldY\<5)) {  
trace(“close”);  
clearInterval(myInterval);  
} else {  
oldX = \_xmouse;  
oldY = \_ymouse;  
}  
}  
mc.onRollOver = function() {  
trace(“open”);  
myInterval = setInterval(checkMouse, 5000);  
Int1 = setInterval(getoldX, 100);  
};  
mc.onRollOut = function() {  
clearInterval(myInterval);  
};

won`t give you exactly 5seconds but should be ok for what you want

---

<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:** [September 4, 2004, 1:48am UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/4 "2004-09-04T01:48:22Z")

</div>

> [@stringy](#):
>
> try something like this
> 
> function getoldX() {  
> oldX = \_xmouse;  
> clearInterval(Int1);  
> }  
> function checkMouse() {  
> if (Math.abs(\_xmouse-oldX\<5) && Math.abs(\_ymouse-oldY\<5)) {  
> trace(“close”);  
> clearInterval(myInterval);  
> } else {  
> oldX = \_xmouse;  
> oldY = \_ymouse;  
> }  
> }  
> mc.onRollOver = function() {  
> trace(“open”);  
> myInterval = setInterval(checkMouse, 5000);  
> Int1 = setInterval(getoldX, 100);  
> };  
> mc.onRollOut = function() {  
> clearInterval(myInterval);  
> };
> 
> won`t give you exactly 5seconds but should be ok for what you want

thanks for the response but the code you provided has a problem… I inserted the code and changed it to match my movie clip name but Im getting a type mismatch error

**Error** Scene=Scene 8, layer=actions, frame=47:Line 7: Type mismatch.  
if (Math.abs(\_xmouse-oldX\<5) && Math.abs(\_ymouse-oldY\<5)) {  
Total ActionScript Errors: 1 Reported Errors: 1

any ideas?

---

<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:** [September 4, 2004, 5:51am UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/5 "2004-09-04T05:51:00Z")

</div>

> [@zerosignal0](#):
>
> thanks for the response but the code you provided has a problem… I inserted the code and changed it to match my movie clip name but Im getting a type mismatch error
> 
> **Error** Scene=Scene 8, layer=actions, frame=47:Line 7: Type mismatch.  
> if (Math.abs(\_xmouse-oldX\<5) && Math.abs(\_ymouse-oldY\<5)) {  
> Total ActionScript Errors: 1 Reported Errors: 1
> 
> any ideas?

sorry, try this  
function getoldX() {  
oldX = \_xmouse;  
clearInterval(Int1);  
}  
function checkMouse() {  
if (Math.abs(\_xmouse-oldX)\<5 && Math.abs(\_ymouse-oldY)\<5) {  
trace(“close”);  
clearInterval(myInterval);  
} else {  
oldX = \_xmouse;  
oldY = \_ymouse;  
}  
}  
mc.onRollOver = function() {  
trace(“open”);  
myInterval = setInterval(checkMouse, 5000);  
Int1 = setInterval(getoldX, 100);  
};  
mc.onRollOut = function() {  
clearInterval(myInterval);  
};

---

<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:** [September 4, 2004, 1:09pm UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/6 "2004-09-04T13:09:14Z")

</div>

lol  
ok no errors now but whenever I rollover my mc it just pops up open on the output box while Im live previewing it… hmm… Im trying to work on it but Im not familiar with a couple of the commands so I dont know if Im going to be able to figure this one out on my own.

---

<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:** [September 4, 2004, 2:52pm UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/7 "2004-09-04T14:52:27Z")

</div>

> [@zerosignal0](#):
>
> lol  
> ok no errors now but whenever I rollover my mc it just pops up open on the output box while Im live previewing it… hmm… Im trying to work on it but Im not familiar with a couple of the commands so I dont know if Im going to be able to figure this one out on my own.

all you have to do is replace the traces with a call to the function(s) which open/close your menu.

---

<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:** [September 4, 2004, 10:21pm UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/8 "2004-09-04T22:21:54Z")

</div>

> [@stringy](#):
>
> all you have to do is replace the traces with a call to the function(s) which open/close your menu.

function getoldX() {  
oldX = \_xmouse;  
clearInterval(Int1);  
}  
function checkMouse() {  
if (Math.abs(\_xmouse-oldX)\<5 && Math.abs(\_ymouse-oldY)\<5) {  
\_root.nav.gotoAndPlay(“down”);  
clearInterval(myInterval);  
} else {  
oldX = \_xmouse;  
oldY = \_ymouse;  
}  
}  
nav.onRollOver = function() {  
\_root.nav.gotoAndPlay(“up”);  
myInterval = setInterval(checkMouse, 5000);  
Int1 = setInterval(getoldX, 100);  
};  
nav.onRollOut = function() {  
clearInterval(myInterval);  
};

well for some reason its still not working so hears what Im putting in. I just cant seem to figure it out… now nothing happens

---

<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:** [September 5, 2004, 12:00am UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/9 "2004-09-05T00:00:37Z")

</div>

> [@zerosignal0](#):
>
> function getoldX() {  
> oldX = \_xmouse;  
> clearInterval(Int1);  
> }  
> function checkMouse() {  
> if (Math.abs(\_xmouse-oldX)\<5 && Math.abs(\_ymouse-oldY)\<5) {  
> \_root.nav.gotoAndPlay(“down”);  
> clearInterval(myInterval);  
> } else {  
> oldX = \_xmouse;  
> oldY = \_ymouse;  
> }  
> }  
> nav.onRollOver = function() {  
> \_root.nav.gotoAndPlay(“up”);  
> myInterval = setInterval(checkMouse, 5000);  
> Int1 = setInterval(getoldX, 100);  
> };  
> nav.onRollOut = function() {  
> clearInterval(myInterval);  
> };
> 
> well for some reason its still not working so hears what Im putting in. I just cant seem to figure it out… now nothing happens

if you upload your fla, i`ll see if i can sort it out for you

---

<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:** [September 5, 2004, 4:07am UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/10 "2004-09-05T04:07:26Z")

</div>

cool Id really appriciate it man

[http://www.zerosignaldesigns.com/fla.zip](http://www.zerosignaldesigns.com/fla.zip)

---

<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:** [September 5, 2004, 9:45am UTC](https://forum.kirupa.com/t/timing-movie-clips/63109/11 "2004-09-05T09:45:15Z")

</div>

> [@zerosignal0](#):
>
> cool Id really appriciate it man
> 
> [http://www.zerosignaldesigns.com/fla.zip](http://www.zerosignaldesigns.com/fla.zip)

can you upload a version without my code which is working . I`m unclear how you are going to use your rollOvers/rollOuts with nav.
