Find and hide suffix _Level code fails on >1 MC
Hi,
Flash CS5 AS3
The following code is designed to hide any MovieClips with _Level2 or _Level3 at the end of their instance name.
I now see its only working if there is one MC on stage with a suffix of _Level2 or _Level3 in its instance name.
Introduce a second MC and only the first remains hidden, all others remain visible.
What should the code be to make this work on more than one MC please ?
The MC's with instance name suffix Level2 or Level3 sit within an MC called Map_Collection as per the code.
for(var i:uint=0; i<this.numChildren; i++){
var object:* = Map_Collection.getChildAt(i);
if(String(object.name).indexOf("_Level2") > -1
|| String(object.name).indexOf("_Level3") > -1 ){
object.visible=false;
}
}
By a sheer fluke I thought it was working, but I now discover all the MC's that were hidden sat within another MC also with suffix _Level2 and it saw that, hid it and hid those within as well....doh !!!!
Envirographics
(P.S. code from NedMurphy...thanks)