# Problem pausing timeling

**URL:** <https://forum.kirupa.com/t/problem-pausing-timeling/120464>\
**Category:** Uncategorized\
**Created:** [August 24, 2004, 3:52pm UTC](https://forum.kirupa.com/t/problem-pausing-timeling/120464 "2004-08-24T15:52:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfmarq](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@sfmarq](https://forum.kirupa.com/u/sfmarq)\
**Post date:** [August 24, 2004, 3:52pm UTC](https://forum.kirupa.com/t/problem-pausing-timeling/120464/1 "2004-08-24T15:52:30Z")

</div>

I’m using this function

function wait(mc, n) {  
mc.stop();  
var myInterval = setInterval(function () {  
mc.play();  
clearInterval(myInterval);  
}, 3 \* 1000);  
}  
\_root.wait(this, n)

To delay events along my timeline. That code works fine. My problem is that is that I also want the user to be able to pause the movie at any time. However, if the pause button I’m using is pressed by the user while the timeline is delayed using this function it starts playing again after the interval even if the pause button is still pressed. How can I override this wiat function with a pause button?

---

<div class="post-metadata">

**Author:** ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)\
**Post date:** [August 24, 2004, 5:47pm UTC](https://forum.kirupa.com/t/problem-pausing-timeling/120464/2 "2004-08-24T17:47:55Z")

</div>

clear the interval before you set it and this should solve it 😉

Prophet.

---

<div class="post-metadata">

**Author:** ![sfmarq](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@sfmarq](https://forum.kirupa.com/u/sfmarq)\
**Post date:** [August 25, 2004, 12:17am UTC](https://forum.kirupa.com/t/problem-pausing-timeling/120464/3 "2004-08-25T00:17:09Z")

</div>

I’m afraid I’m an actionscript beginner. How and where exactly do I put the clearInterval?

Mark

> [@Prophet](#):
>
> clear the interval before you set it and this should solve it 😉
> 
> Prophet.

---

<div class="post-metadata">

**Author:** ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)\
**Post date:** [August 25, 2004, 6:09pm UTC](https://forum.kirupa.com/t/problem-pausing-timeling/120464/4 "2004-08-25T18:09:33Z")

</div>

```auto
function wait(mc, n) {
     mc.stop()
     clearInterval(myInterval)
     var myInterval = setInterval(function () {
         mc.play()
         clearInterval(myInterval)
     }, 3000)
  }
 _root.wait(this, n)

```

note i just changed your interval time to take up less characters… apologies if that annoys u but meh - personal preference 😉 same thing goes for the semi-colons ; 🙂

Prophet.

---

<div class="post-metadata">

**Author:** ![sfmarq](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@sfmarq](https://forum.kirupa.com/u/sfmarq)\
**Post date:** [August 25, 2004, 6:55pm UTC](https://forum.kirupa.com/t/problem-pausing-timeling/120464/5 "2004-08-25T18:55:00Z")

</div>

Thanks for your help.

Mark

---

<div class="post-metadata">

**Author:** ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)\
**Post date:** [August 25, 2004, 10:14pm UTC](https://forum.kirupa.com/t/problem-pausing-timeling/120464/6 "2004-08-25T22:14:39Z")

</div>

no prob 🙂

Prophet.
