# Change colors

**URL:** <https://forum.kirupa.com/t/change-colors/32563>\
**Category:** Uncategorized\
**Created:** [October 8, 2003, 1:56pm UTC](https://forum.kirupa.com/t/change-colors/32563 "2003-10-08T13:56:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dizzylistener](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@dizzylistener](https://forum.kirupa.com/u/dizzylistener)\
**Post date:** [October 8, 2003, 1:56pm UTC](https://forum.kirupa.com/t/change-colors/32563/1 "2003-10-08T13:56:18Z")

</div>

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,

Thijs
