Groups | Blog | Home
all groups > flash actionscript > january 2004 >

flash actionscript : simple loop referencing buttons won't work!


Mikey23
1/22/2004 11:07:35 PM
hello all,

ok im basically just trying to set the alpha of all my buttons on the stage to 30.

my buttons are name b1,b2,b3 etc.

if i put in the code
b1._alpha = 30;

this works fine. now i just want to use a loop to go through them all, but i can't do it.
This is the code i thought would work, but it obv doesn't.

for (i=1 ; i < 5 ; i++) {
b._alpha = 30;
}

I've tried just about every combination possible, but it wont work!

HELP ME PLEASEEEEEEE!

thanks
Mike


Andre Hessler
1/23/2004 12:34:49 AM
Hi Mike!

you have to put the b and the i together. use b like a string an i as
variable. Make sure, your buttons are on the maintimeline (Mainstage).
Otherwise replays the word _root.

try this:
for (i=1; i<5; i++) {
_root["b"+i]._alpha = 30; //No "." after _root!
}

....it always works like this!

Bye
-André-




[quoted text, click to view]

AddThis Social Bookmark Button