# Dynamic attached button\_mc + targetting proper value

**URL:** <https://forum.kirupa.com/t/dynamic-attached-button-mc-targetting-proper-value/180719>\
**Category:** Uncategorized\
**Created:** [March 3, 2006, 12:57am UTC](https://forum.kirupa.com/t/dynamic-attached-button-mc-targetting-proper-value/180719 "2006-03-03T00:57:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristessa](https://avatars.discourse-cdn.com/v4/letter/t/a88e4f/32.png) [@tristessa](https://forum.kirupa.com/u/tristessa)\
**Post date:** [March 3, 2006, 12:57am UTC](https://forum.kirupa.com/t/dynamic-attached-button-mc-targetting-proper-value/180719/1 "2006-03-03T00:57:58Z")

</div>

Hi once more

so i’ve managed to get flash building up a menu that reads from a xml file  
it nicely attaches buttons for the amount of nodes i want to be shown  
(11 in this case) it will change over time, and i don’t feel like recoding every button behavior everytime the menu needs to get updated, cheers for dynamic…

all the names are filled in nicely, but 1 thing is missing and i can’t find out where my mistake could be.  
i’ve spent over 3 days now, fiddling around with the code, yet nothing works, or works half…

here is the deal:  
ps the theName\_str is is “masked” for obvious reasons

```auto

var i:Number;
        var theName_str:String = "/place/to/look/for";
        var name_array:Array = XPathAPI.selectNodeList(this.firstChild, theName_str);
        for (i=0; i<name_array.length; i++) {
            var SB = attachMovie("sub", "buttonsub"+i, i);
SB.btntxt.text = name_array*.firstChild.nodeValue;
            trace("	"+i+"."+name_array*.firstChild.nodeValue);
SB.onRelease = function() {
                trace("	"+i+"."+name_array*.firstChild.nodeValue);
}
}

```

so this in the output gives me nicely all the values i want in the button textfields.

yet if i press a button , the output gives me something like

```auto
SB.11 undefined

```

11 stands for the amount of nodes that is being loaded.

when i change the code to

```auto

  SB.onRelease = function() {
                  trace(SB + "."+name_array*.firstChild.nodeValue);
  
  

```

this traces in the output… it’s very confusing for me at this point

```auto
_level0.SB10.undefined

```

so i’d like to know how i could trace for example when i press the third button, it says SB.03 name of the corresponding node

so in other words SB.03 in the textfield says kirupa  
how do i trace when i click on it “sb.03 kirupa”

i hope this is well written for someone to understand, my english isn’t that well. is there anyone here that wishes to guide me? much appreciated

kind regards  
triss :h:
