Clearing the actions on a specific frame

I have this timer code on the first frame of the movie.

function pause() {
	play();
	clearInterval(timer);
}

stop();
timer = setInterval(pause, 3000);

And I want it to perform this timer until I press a button on the main stage.

I found some information about clearing the actions from a movie clip but I didn’t see much about clearing it from a frame.

Any ideas?