setInterval

Wednesday, October 08, 2003 5:03 AM

Hi,

I have this problem that’s bugging me for days now.

I have a list of buttons, en what I’m trying to do is when you click on a button, it changes color.

The color of the text of the original button is blue. On top is a movieClip with the same text but in black.
So when you click a button I want to change the _alpha property from the black movieclip to 0. Meanwhile the _alpha of the rest of the buttons must be set back to 100; so if a button is already blue, it becomes black again.

Here’s my code:
the maximum value of the list of buttons is saved in ‘max_array’

function anim(mc_huidig) {// function anim starts when you click ‘mc_huidig’
for (i=0; i<max_array+1; i++) {
mc = eval(“newsitem”+i);
if (mc == mc_huidig) {
fadein = setInterval(actief, 10, mc);
} else {
fadeout = setInterval(deactief, 10, mc);
}
}
}
function actief(mc) {
if (mc.darken._alpha > 0) {
mc.darken._alpha -= 10;
} else {
//trace(“stop fadein”);
clearInterval(fadein);
}
}
function deactief(mc) {
if (mc.darken._alpha < 100) {
mc.darken._alpha += 10;
} else {
//trace(“stop fadeout”);
clearInterval(fadeout);
}
}

Any blue buttons doe become black again, but the turning into blue happens only the first time I click a button, the second button doesn’t become blue (or very slowly).
When I use the trace on ‘deactief’, it does the trace but the trace keep going on, it never stops. It seems to me that “clearInterval(fadeout);” doesn’t happen.

I don’t know what I’m doing wrong.

Can someone please help me?

Thx in advance,

dizzy