PDA

View Full Version : Simple setInterval Problem?


Llama_Boy
01-22-2009, 08:00 PM
hey everyone

Here's the situation. I have a counter moving round a board. Nothing particularly spectacular so i thought i'd jazz it up a bit by making the counter fade out, moves to it's new position while still invisible, then fade back in. With some cool tardis sounds in the background.

Here's what i've got:
function fadeOut(clippy:MovieClip){
clippy._alpha -= 5;
if(clippy._alpha < 0){
clearInterval(callFadeOut);
spaceMove();
clippy._alpha = 0;
var callFadeIn = setInterval(fadeIn, 50, Counter);
}
}

function fadeIn(clippo:MovieClip){
clippo._alpha += 5;
if(clippo._alpha > 100){
clearInterval(callFadeIn);
clippo._alpha = 100;
}
}
With this in a button:
var callFadeOut = setInterval(fadeOut, 90, Counter);

It works perfectly fine for the first turn, but on the next turn it just flickers and stays static.
I thought it might be a problem with placing a setInterval call within the function being called by the first, but i clear the first before the second runs so it should work right?

Any help would be greatly appreciated, LB