PDA

View Full Version : Hopefully Easy Variable Question?



Ibanez271
February 27th, 2008, 02:19 PM
I have a set of 5 buttons named

sysAdmin1Btn
sysAdmin2Btn
sysAdmin3Btn
sysAdmin4Btn
sysAdmin5Btn

Is there a way to have a counter variable be put in place of the number and still be able to access the var?
Ex.



var count:int = 0;
for(var int:i = 0; i < 5; ++i)
{
//I want to be able to access all the var's through this, maybe something like
//this even though it does not work?
sysAdmin{count+1}Btn.visible = false;
}

corneliu9d
February 27th, 2008, 02:50 PM
This is solved like this:


this["sysAdmin"+count+1+"Btn"].visible=false;

Though I never use the number inside the object's name, but at the end, like sysAdminBtn5 or so. It should work, anyway.

Ibanez271
February 27th, 2008, 03:01 PM
This is solved like this:


this["sysAdmin"+count+1+"Btn"].visible=false;

Though I never use the number inside the object's name, but at the end, like sysAdminBtn5 or so. It should work, anyway.

Great! It worked, Thanks.