# How to use XML data to reference an instance name

**URL:** <https://forum.kirupa.com/t/how-to-use-xml-data-to-reference-an-instance-name/306520>\
**Category:** flash\
**Created:** [March 16, 2010, 11:09pm UTC](https://forum.kirupa.com/t/how-to-use-xml-data-to-reference-an-instance-name/306520 "2010-03-16T23:09:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lackmaster](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lackmaster](https://forum.kirupa.com/u/lackmaster)\
**Post date:** [March 16, 2010, 11:09pm UTC](https://forum.kirupa.com/t/how-to-use-xml-data-to-reference-an-instance-name/306520/1 "2010-03-16T23:09:12Z")

</div>

I have 6 movieclips on the stage, each with a unique instance name. I just want to put them in order determined from an external xml file.

I can get the name and order of each instance name evident from a trace, but I can’t use that xml variable name to position the x on the stage.

Seems simple, but it won’t let me use the variable as an instance name:

//begin AS3

var loader:URLLoader = new URLLoader();  
var xml:XML = new XML();  
var i:Number = 0;

loader.addEventListener(Event.COMPLETE, onLoaded);

loader.load(new URLRequest(“xml/config.xml”));

function onLoaded(e:Event):void  
{  
xml = new XML(e.target.data);  
ParseData(xml);  
actionPanel.apText.htmlText = xml.BreastAug.ActionPanel1;  
//trace(xml._.length());  
var bTotal:Number = (xml._.length());  
trace(bTotal);  
}

function ParseData(dataInput:XML):void {

var attributes:XMLList = dataInput.children().attributes();

for each (var buttonName:XML in attributes) {  
trace(buttonName);  
trace(i);  
buttons.buttonName.x = i; //THIS DOESN’T WORK  
i = i + 225;  
}  
}  
//end AS3

trace output:  
button2  
0  
button1  
225  
button3  
450  
button4  
675  
4

In the output, button2 = the instance name of the button already on the stage.

I appreciate any help or insight, and sorry of the is a dumb way of coding something.
