# setInterval to Cancel via Button

**URL:** <https://forum.kirupa.com/t/setinterval-to-cancel-via-button/188494>\
**Category:** flash\
**Created:** [May 8, 2006, 2:52pm UTC](https://forum.kirupa.com/t/setinterval-to-cancel-via-button/188494 "2006-05-08T14:52:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skruffylooking](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@skruffylooking](https://forum.kirupa.com/u/skruffylooking)\
**Post date:** [May 8, 2006, 2:52pm UTC](https://forum.kirupa.com/t/setinterval-to-cancel-via-button/188494/1 "2006-05-08T14:52:58Z")

</div>

Hi.

I’m making a powerpoint-like presentation that uses a setInterval every few frames to pause the presentation and then a clearInterval to resume play after 2-4 seconds.

I also would like to pause the movie using a button, which does work when the movie is playing, but does NOT work when a setInterval is in motion. Is there some way I can get a pause button to cancel out the delay and pause the movie manually?

Delay code:

```auto
stop();
var nDelayID = setInterval(this, "pause", 1000);
function pause() {
clearInterval(nDelayID);
play();
}

```

The Pause/Play button is a movieclip with two frames (pause and play label frames)…  
Button code:

```auto
 on (press) {
    _root.stop();
    nextFrame();
    function pause() {
        _root.clearInterval(nDelayID);
    }
}

```

SWF file…(because i can’t fit the FLA file here)
