# setInterval to stop while the mouse is on a button

**URL:** <https://forum.kirupa.com/t/setinterval-to-stop-while-the-mouse-is-on-a-button/262179>\
**Category:** flash\
**Created:** [June 3, 2008, 11:14pm UTC](https://forum.kirupa.com/t/setinterval-to-stop-while-the-mouse-is-on-a-button/262179 "2008-06-03T23:14:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brostd](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@brostd](https://forum.kirupa.com/u/brostd)\
**Post date:** [June 3, 2008, 11:14pm UTC](https://forum.kirupa.com/t/setinterval-to-stop-while-the-mouse-is-on-a-button/262179/1 "2008-06-03T23:14:09Z")

</div>

On my movie i have a timer going in the background to reload some images after a set amount of time. I would like it to stop the timer while i have the mouse rolled over the button. I figured it would be easy but i cannot seem to find how to do this anywhere.

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [June 4, 2008, 5:41pm UTC](https://forum.kirupa.com/t/setinterval-to-stop-while-the-mouse-is-on-a-button/262179/2 "2008-06-04T17:41:56Z")

</div>

```auto

var intervalID:Number = setInterval(yourFunc, 1000);

clearInterval(intervalID);

```

first line creates the interval and stores a reference to its ID in the intervalID variable, second line you call when you want to stop the interval running
