# Cant clearInterval

**URL:** https://forum.kirupa.com/t/cant-clearinterval/201830
**Category:** Uncategorized
**Created:** [September 25, 2006, 3:28pm UTC](https://forum.kirupa.com/t/cant-clearinterval/201830 "2006-09-25T15:28:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dru\_nasty](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dru\_nasty](https://forum.kirupa.com/u/dru_nasty)
#### Post date: [September 25, 2006, 3:28pm UTC](https://forum.kirupa.com/t/cant-clearinterval/201830/1 "2006-09-25T15:28:21Z")

</div>

I’ve got 4 mc’s (flame1,flame2,etc…) that im trying to fade out in a sequence using setInterval. Here’s the code:

```auto

function fadeOutFlame(target) {
	target._alpha = 100;
	var speed = 8;
	target.onEnterFrame = function() {
		if(target._alpha >= 0){
		target._alpha -= speed;
		clearInterval(ID1);
		clearInterval(ID2);
		clearInterval(ID3);
		clearInterval(ID4);
		}else{
			delete target.onEnterFrame;
		}
	};
}

ID1 = setInterval( fadeOutFlame, 1000, flame1);
ID2 = setInterval( fadeOutFlame, 3000, flame2);
ID3 = setInterval( fadeOutFlame, 5000, flame3);
ID4 = setInterval( fadeOutFlame, 7000, flame4);

```

Where I have clearInterval (4x’s) only flame1 will fade out and the rest won’t.  
If I remove all the clearIntervals they all fade out in sequence as they should but keep repeating the fadeout function. How can I fix this? Also is there a way to clean this up with a loop maybe?
