Note:I have to write this AS3 project on the timeline, which is why I’m not using classes.
I have a movieclip on the root with variable name “dropdownMenu_mc”.
On the timeline, there’s an action frame with all the actions. I have a for loop which adds a bunch of buttons from my library into the dropdownMenu_mc (via addChild) and I dynamically assign them all names.
for (var i=0; i<item_count; i++) {
if(xml_menucontent.attribute(“menuname”)* != “DIVIDER”){
var newMB:menuBtn = new menuBtn();
MovieClip(dropdownMenu_mc).addChild(newMB);
newMB.x = originX;
newMB.y = originY;
newMB.menuName_mc.name_txt.text = xml_menucontent.attribute(“menuname”);
newMB.menuTitle = xml_menucontent.attribute(“name”);
newMB.movieName = xml_menucontent.attribute(“executable”);
[COLOR=“red”]newMB.name = “menuButton”+;[/COLOR]
newMB.addEventListener(MouseEvent.CLICK, loadMenuMovie);
//trace(newMB.movieName);
originY += 33;
}
}
Now, later on, I want to be able to go into each of those menu buttons and do various things to the movieclips and textfields that are inside of that clip. Example:
MovieClip(root).dropdownMenu_mc.[COLOR=“red”]menuButton1[/COLOR].current_slide_mc.page_txt.text = “1”;
Why do I get an error for that? Why can’t [COLOR=“Red”]menuButton1[/COLOR] be found? It was assigned the variable name in the for loop above.