# Binding XML data to dynamic text inside MC

**URL:** <https://forum.kirupa.com/t/binding-xml-data-to-dynamic-text-inside-mc/168749>\
**Category:** flash\
**Created:** [November 9, 2005, 6:25pm UTC](https://forum.kirupa.com/t/binding-xml-data-to-dynamic-text-inside-mc/168749 "2005-11-09T18:25:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heenan](https://avatars.discourse-cdn.com/v4/letter/h/7feea3/32.png) [@Heenan](https://forum.kirupa.com/u/Heenan)\
**Post date:** [November 9, 2005, 6:25pm UTC](https://forum.kirupa.com/t/binding-xml-data-to-dynamic-text-inside-mc/168749/1 "2005-11-09T18:25:20Z")

</div>

Hello all,

I am having issues binding some XML data that I am looping through to a MC. Imagine if you will about 100 MCs on the stage, each with incrementing numbers in their instance names (ie. mc\_locker1, mc\_locker2, mc\_locker3…). I want to be able to loop through the XML, then bind that data to the corresponding MC. Here is a snippet of code thus far:

function loadXML(loaded) {  
if (loaded) {  
id = [];  
usage = [];  
totalLength = this.firstChild.childNodes.length;  
for (x=0; x\<totalLength; x++) {  
id[x] = this.firstChild.childNodes[x].childNodes[0].firstChild.nodeValue;  
usage[x] = this.firstChild.childNodes[x].childNodes[1].firstChild.nodeValue;

this works —\> mc\_locker1.unique\_txt.txt = id[x];  
this does not but needs to —\> someVariableName+x.unique\_txt.text = id[x];

}  
}

The problem is that I have to specifically assign the MC instance name (mc\_locker1) to the data binding. But remember I have over 100 MCs on the stage so that would be silly. I need a way to set up a variable so that I can concatenate the string and then loop accordingly (ie. lockers = “mc\_locker” + (x+1) + ".unique\_txt.text) but that does not work.

Is there an issue with not being able to access attributes when a variable is used?

Any help would be appreciated.

Thanks.
