# setInterval for on(rollOver)

**URL:** <https://forum.kirupa.com/t/setinterval-for-on-rollover/34601>\
**Category:** Uncategorized\
**Created:** [November 4, 2003, 1:16pm UTC](https://forum.kirupa.com/t/setinterval-for-on-rollover/34601 "2003-11-04T13:16:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KeeJera](https://avatars.discourse-cdn.com/v4/letter/k/ecd19e/32.png) [@KeeJera](https://forum.kirupa.com/u/KeeJera)\
**Post date:** [November 4, 2003, 1:16pm UTC](https://forum.kirupa.com/t/setinterval-for-on-rollover/34601/1 "2003-11-04T13:16:52Z")

</div>

This has probably been answered before but I couldn’t seem to find it. (I am fairly new to this site and FlashMX)

I have up and down buttons controlling the .\_y value of an adjacent MClip. At the (for the up arrow) moment I have:  
on(rollOver){  
myMovieClip.\_y -= 5;  
}  
this works fine but I need it to continuously scroll while the mouse is over (or Press if need be).  
I think it is setInterval that I need for this but I can’t remember how to do it.

Can someone help with this?

Thanks in advance. :thumb:

---

<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:** [November 4, 2003, 1:28pm UTC](https://forum.kirupa.com/t/setinterval-for-on-rollover/34601/2 "2003-11-04T13:28:09Z")

</div>

on(rollOver){  
myMovieClip.onEnterFrame = function(){  
this.\_y -= 5;  
}  
}  
on(rollOut){  
myMovieClip.onEnterFrame = undefined;  
}

this is assuming u are applying the events to the button directly

---

<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:** [November 4, 2003, 2:01pm UTC](https://forum.kirupa.com/t/setinterval-for-on-rollover/34601/3 "2003-11-04T14:01:28Z")

</div>

Thanks for that. Worked a treat. Exactly what I was after.

Can it be done with setInterval too though?

---

<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:** [November 4, 2003, 2:57pm UTC](https://forum.kirupa.com/t/setinterval-for-on-rollover/34601/4 "2003-11-04T14:57:00Z")

</div>

Yes:  
[AS]  
on(rollOver){  
if(!this.intervalID){  
this.intervalID = setInterval(“move”, 30);  
}  
}  
move = function(){  
this.myMovieClip.\_y -= 5;  
}

on(rollOut){  
clearInterval(this.intervalID);  
this.intervalID = 0;  
}

[/AS]

SHO
