I have variable names stored in an array, and I want to loop through array and set the visible property of that instance to false. However, I'm getting error;
Error #1056: Cannot create property visible on String.
Here is my code:
package {
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class touch extends MovieClip
{
public function touch()
{
var menuitems:Array = new Array("menu_One", "menu_Two", "menu_Three", "menu_Three", "menu_Four", "menu_Five");//array with instance names
for(var i:int=0;i<6;i++){
var tempName = menuitems[i];
bsF_txt.text = tempName;
trace(tempName);
tempName.visible = false;
//menu_One.visible = false;
}
}
}
}
Is. what I'm trying to do possible in AS3?
StringObject in As3 does not have a visible parameter. There is no .visible forStringwhich is causing your error. What are you trying to accomplish? It would work if you had say movieclips instead of a string... I just noticed your comment that those strings are instance names so I added an answer below