Copy link to clipboard
Copied
Hey guys,
What I am trying to do should be very simple, I want to make several movieclip objects not visible by using a for loop.
Here is what I currently have...
for (var i:Number=1; i<8; i++){
high.visible = false;
}
So I have 8 movieclip objects that have instance names of "high1", "high2", "high3" and so forth up to 8
What would be the correct syntax for this line of code to make this work?
high.visible = false;
Thank you.
You can use String values to target instances if you use bracket notation:
for (var i:Number=1; i<8; i++){
this["high" +String(i)].visible = false;
}
Copy link to clipboard
Copied
You can use String values to target instances if you use bracket notation:
for (var i:Number=1; i<8; i++){
this["high" +String(i)].visible = false;
}
Copy link to clipboard
Copied
Thank You so much to both of you, that works perfect!
Copy link to clipboard
Copied
You're welcome
Copy link to clipboard
Copied
All credit goes to Ned he wrote faster and better
Copy link to clipboard
Copied
Haha both of you answered at the same time literally. Wish i could mark you both correct
Copy link to clipboard
Copied
for (var i:Number=1; i<8; i++){
this["high"+i].visible = false;
}