PDA

View Full Version : Making a for-loop with Button Variable



eddepet
July 31st, 2002, 04:57 AM
Hello,

I have a small problem and I hope you know if this is possible.

The situation is like this:
I have Five buttons named button1 to Button5.
What I want is to make one button invisible.
To to this I have a for 1 to 5 -loop and I want to make one button invisible if it meets certain criteria.

Is this possible without make an if-line for each button or not??

I hope One of You can help me, Thanx in advance.

KarenInPA
July 31st, 2002, 07:27 AM
Sure.

Try:



//event happens to make one of the buttons disappear (button press, frame entry, whatever...)

buttonNum = 5;

for(i = 1; i<=buttonNum; i++)
if(button[i] condition) {
button[i]._visible = false;
}
}


-Karen

eddepet
July 31st, 2002, 10:34 AM
I have tried this but the button stays visible.

I have tried names like Button1 or Button[1] but both don't respond.
If I try it with both named Button1 then the button is indeed invisible.

Is there an other place to enter a name or did I do it wrong??

Thanks in advance.

pom
July 31st, 2002, 04:08 PM
Hey Karen, what is button[i] supposed to be? An element of an array?

pom :asian:

And I'm repeating: I love your footer, it's brilliant!

KarenInPA
July 31st, 2002, 05:18 PM
hmmmm.



button[i] = _root.karenInPA.with.no.coffee;



I have to watch my, um, "illustrative" posts. The code will work if the buttons are nested in numbered movie clips (i.e. buttonMC1, buttonMC2, etc.) and targeted properly (i.e. not like my gibberish code above) in the loop.

My apologies. I will try to think-then-speak from now on. :)

Karen

PS.. Thanks again on the footer! It's so cool you noticed it.