Copy link to clipboard
Copied
Can this code be made shorter or leaner?
a_btn.useHandCursor = true;
b_btn.useHandCursor = true;
c_btn.useHandCursor = true;
d_btn.useHandCursor = true;
e_btn.useHandCursor = true;
f_btn.useHandCursor = true;
g_btn.useHandCursor = true;
h_btn.useHandCursor = true;
i_btn.useHandCursor = true;
j_btn.useHandCursor = true;
k_btn.useHandCursor = true;
l_btn.useHandCursor = true;
Thanks
for(var i:uint=0; i<btns.length; i++){
btns.useHandCursor = true;
}
Copy link to clipboard
Copied
Because you are using letters rather than numbers it becomes a little less able to be done efficiently as far as the amount of code needed goes.
One way would be to just put the instance names in an array and loop thru the array to assign the property.
btns[#].useHandCursor = true; // where # is the loop increment
Another could be to just have the unique letter elements of the button instance names in an array and use bracket notation to target the buttons to assign the properties.
this[letters[#]+"_btn"].useHandCursor = true; // same deal with #
Copy link to clipboard
Copied
Hello Ned. Thank you.
What type of loop? Can you provide a sample?
Thanks
Copy link to clipboard
Copied
for(var i:uint=0; i<btns.length; i++){
btns.useHandCursor = true;
}
Copy link to clipboard
Copied
Thanks Ned!!!
Copy link to clipboard
Copied
You're welcome