Dynamic attached button_mc + targetting proper value

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


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

SB.11 undefined

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

when i change the code to


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

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

_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: