I’ve got 4 mc’s (flame1,flame2,etc…) that im trying to fade out in a sequence using setInterval. Here’s the code:
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?