# setInterval and btn control?

**URL:** <https://forum.kirupa.com/t/setinterval-and-btn-control/85719>\
**Category:** flash\
**Created:** [April 6, 2005, 10:42pm UTC](https://forum.kirupa.com/t/setinterval-and-btn-control/85719 "2005-04-06T22:42:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yossarian](https://avatars.discourse-cdn.com/v4/letter/y/9de0a6/32.png) [@yossarian](https://forum.kirupa.com/u/yossarian)\
**Post date:** [April 6, 2005, 10:42pm UTC](https://forum.kirupa.com/t/setinterval-and-btn-control/85719/1 "2005-04-06T22:42:35Z")

</div>

I want a button which starts the timer function when pressed and I can’t get it to do that!  
This is the code I’ve written for the button:

```auto

on (press){
displayTime = 45; 
  	countDown = function(message){
  
  		displayTime--; 
  		if (displayTime == 0){
  
  			clearInterval(timer); 
  			gotoAndStop ("Time");
		}
  		}
}

```

and this for the frame above

```auto

timer = setInterval(countDown, 1000);

```

Any idea how I can make the button start the timer function?

Yossi
