# Setinterval script causing problems

**URL:** <https://forum.kirupa.com/t/setinterval-script-causing-problems/108668>\
**Category:** Uncategorized\
**Created:** [April 27, 2004, 6:15pm UTC](https://forum.kirupa.com/t/setinterval-script-causing-problems/108668 "2004-04-27T18:15:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandman9](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@Sandman9](https://forum.kirupa.com/u/Sandman9)\
**Post date:** [April 27, 2004, 6:15pm UTC](https://forum.kirupa.com/t/setinterval-script-causing-problems/108668/1 "2004-04-27T18:15:10Z")

</div>

Ok here’s good practice for you ActionScript wizards out there.

I have 6 buttons. When clicked they are assigned a value (num =1 for button 1 and 2 for button 2, etc). Then there’s 6 corresponding MC which are numbered from 1-6. If num = 1 then MC1 plays. And if num=2 then MC2 play, etc.

Pretty simple stuff so far. Although a problem was that if you click button one and then you click say button 3, I needed the animation in MC1 to stop so the animation in MC3 can start. So for this I had

```auto

this.onEnterFrame = function() {
	if (_root.click != num) {
		this.onEnterFrame = {};
		gotoAndStop(1);
	}
};

```

This worked great. It stopped the MC animation. Although in these same MC’s I have added a setinterval script as well

```auto

stop();
timer = function(){
        gotoAndPlay("2bubble");
        clearInterval(playInterval);
}
playInterval = setInterval(timer,6000);

```

So now when you click button 1 and then you click say button 3 the animation in button 1 does not stop. So it appears that first function up above is not being read. Anyone know why? Anyone had a similar problem with setInterval in the past?

Sandman9
