# Accessing values in an xmllist array

**URL:** <https://forum.kirupa.com/t/accessing-values-in-an-xmllist-array/325637>\
**Category:** Uncategorized\
**Created:** [October 27, 2011, 4:57am UTC](https://forum.kirupa.com/t/accessing-values-in-an-xmllist-array/325637 "2011-10-27T04:57:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronmac](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ronmac](https://forum.kirupa.com/u/ronmac)\
**Post date:** [October 27, 2011, 4:57am UTC](https://forum.kirupa.com/t/accessing-values-in-an-xmllist-array/325637/1 "2011-10-27T04:57:00Z")

</div>

I’m having a small problem here.

I’m attaching an array of objects to the stage, each with a x and y values from an external xml. I have 2 values for the y property.

So when I attach the objects to the stage y property takes the first y values. When I want to change the y value to the send y value I am only accessing the last value in the list. What am I doing wrong?

///the external xml file

\<?xml version=“1.0” encoding=“utf-8”?\>  
\<Tickers\>  
\<Ticker\>  
\<lat\>100 \</lat\>  
\<lon\> 100\</lon\>  
\<lon2\>150\</lon2\>  
\</Ticker\>

\<Ticker\>  
\<lat\>100 \</lat\>  
\<lon\> 150\</lon\>  
\<lon2\>200\</lon2\>  
\</Ticker\>

\<Ticker\>  
\<lat\>100 \</lat\>  
\<lon\> 200\</lon\>  
\<lon2\>250\</lon2\>  
\</Ticker\>  
\</Tickers\>

///the code

var tickerList1:XMLList;  
var tickerList2:XMLList;  
var tickerList3:XMLList;  
var data:XML;  
var tickerIndex:int=0;  
var box:redBox;  
var nodex:int;  
var nodey:int;  
var nodey2:int;  
var i:int;

var loader:URLLoader = new URLLoader();  
loader.load(new URLRequest(“events.xml”));  
loader.addEventListener(Event.COMPLETE, LoadXML);

function LoadXML(event:Event):void {  
var data:XML=new XML(loader.data);  
tickerList1=data.Ticker.lat;  
tickerList2=data.Ticker.lon;  
tickerList3=data.Ticker.lon2;

```
for (i = 0; i &lt; tickerList1.length(); i++) {
	nodex=tickerList1[ID=i];
	nodey=tickerList2[ID=i];
	nodey2=tickerList3[ID=i];
	redbox=attachRedBoxes();
}

```

}

function attachRedBoxes() {  
box = new redBox ();  
box.x=nodex;  
box.y=nodey;  
box.ID=i;  
addChild(box);  
}

///the button to change the y property

btn.addEventListener(MouseEvent.MOUSE\_DOWN,change\_ypos);  
function change\_ypos(e:MouseEvent):void {   
for (i=numChildren-1; i\>=0; i–) {  
getChildAt(i).y=nodey2;  
}
