# setInterval to cancel using a button action?

**URL:** <https://forum.kirupa.com/t/setinterval-to-cancel-using-a-button-action/188009>\
**Category:** flash\
**Created:** [May 3, 2006, 7:30pm UTC](https://forum.kirupa.com/t/setinterval-to-cancel-using-a-button-action/188009 "2006-05-03T19:30:42Z")\
**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 3, 2006, 7:30pm UTC](https://forum.kirupa.com/t/setinterval-to-cancel-using-a-button-action/188009/1 "2006-05-03T19:30:42Z")

</div>

Hi All,

I’m making a Flash email that will have a: presentation and buttons on the bottom to either: go back, pause, or move forward.

To kill the mounds of tweening, I am using on the main timeline this code to pause the movie for a set # of seconds, so that a reader can read the text:

```auto
stop();
var delaymov:Number = setInterval(this, "pause", 300);
function pause():Void {
clearInterval(delaymov);
play();
}

```

However, I also want to be able to allow the user to PAUSE (via Movieclip Button) the movie on his/her whim, and just as anticipated, this causes friction with the points of the movie that have the aforementioned script.

Here is what I have for a button function so far.:  
[COLOR=DarkOrange][COLOR=Black]Main Timeline has a  
Movieclip Button that has  
3 Frames: (1)PauseFrame (2)PlayFrame (3)gotoandplay.  
Inside Frames 1 and 2 are buttons for their respective functions.[/COLOR]

[/COLOR]…Code for the Pause Frame’s button:

```auto
on (release) {
    nextFrame(); //advance to next this.frame
    _root.stop(); //pause movie
     clearInterval(delaymov); //disable delay
}

```

I have tried even \_root.clearinterval, and tried to put it in a function  
\_root.stop()  
function() {  
clearInterval(delaymov);  
}  
nextFrame();

but can’t get it to work either way. But it DOES pause the movie when there isn’t a setInterval in the pipes.

Help?

Thanks in Advance!
