# Variable name issue

**URL:** <https://forum.kirupa.com/t/variable-name-issue/293055>\
**Category:** Uncategorized\
**Created:** [July 22, 2009, 4:15pm UTC](https://forum.kirupa.com/t/variable-name-issue/293055 "2009-07-22T16:15:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freeseus](https://avatars.discourse-cdn.com/v4/letter/f/9e8a1a/32.png) [@Freeseus](https://forum.kirupa.com/u/Freeseus)\
**Post date:** [July 22, 2009, 4:15pm UTC](https://forum.kirupa.com/t/variable-name-issue/293055/1 "2009-07-22T16:15:27Z")

</div>

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.
