I need to get a grip on arrays and XML data but I'm having trouble understanding how to turn xml data into useful data. I was hoping these forums might provide some insight.

I load my XML with this code:

```
//set values for XML data file
private var XML_URL:String = "http://www.mysite.com/media/locXML.xml";
private var locXML:XML = new XML();

private function getXMLdata():void
{
    var locXMLURL:URLRequest = new URLRequest(XML_URL);
    var locXMLLoader:URLLoader = new URLLoader(locXMLURL);
    locXMLLoader.addEventListener("complete", xmlLoaded);

    function xmlLoaded(event:Event):void
    {
        locXML = XML(locXMLLoader.data);
        trace("Data loaded. " + locXML);
    }
}

```

I am trying to make the following code into an array populated by that XML data. Everywhere you see a '[]' I need the number to match the number record of the locXML file...

```
    for each (var point[]:XML in locXML.location)
    {
        pointMarker] = new PointMarker();
        pointMarker[].buttonMode = pointMarker[].useHandCursor = true;
        var image[]:Loader = new Loader();
        image[].load(image[]Req, context);
        image[].x = -iconHeight/2;
        image[].y = -iconWidth/2;
        if (pointMarker[]_motion == true)
        {
            var iconShimmer[]:MovieClip = new IconShimmer() as MovieClip;
            iconShimmer[].x = image[].x;
            iconShimmer[].y = image[].y;
            pointMarker[].addChild(image[]);
            pointMarker[].addChild(iconShimmer[]);
            pointMarker[].pointName[] = point[].name;
            pointMarker[].name = imageBubbleFile[];
        }else{
            pointMarker[].addChild(image[]);
            pointMarker[].pointName[] = point[].name;
            pointMarker[].name = imageBubbleFile[];
        }
        pointMarker[].pointDesc[] = point[].description;
        _map.putMarker(new Location(point[].lat, point[].long), pointMarker[]);
        pointMarker[].addEventListener(MouseEvent.CLICK, pointMarker[]_Click);
        pointMarker[].addEventListener(MouseEvent.ROLL_OVER, pointMarker[]_RO);
        pointMarker[].mouseChildren=false;
    }       
}
}

```

here is a small snippet of the XML file:

```
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<location ID="maplogo">
<name>mapLogo</name>
<lat>31.3731712263342</lat>
<long>-94.08871702323849</long>
<iconFile>town.jpg</iconFile>
<imageFile>type1.swf</imageFile>
<motion>false</motion>
</location>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<location ID="bigstarsupermarket">
<name>Big Star Supermarket</name>
<lat>31.5664202</lat>
<long>-93.4904959</long>
<iconFile>bigStar.jpg</iconFile>
<imageFile>type1.swf</imageFile>
<motion>false</motion>
</location>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
</root>

```

how can I do that without taking up 2000 lines of code? I was hard coding a number in each one of those '[]' brackets, but that is becoming very painstaking...?

EDIT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~EDIT
I changed it to where it will loop during the parsing of the xml. but an error is generated for each of this type formating ["icon"+XMLpCounter]

```
    public function parseLocXML(nodeName:String, lat:Number, 
         long:Number, iconFile:String, 
         imageFile:String, motion:String):void

    {   
        if (XMLpCounter==0)
        {
        //addMarkers();
        //trace(arguments);
        //trace("--- drawMap ---");
        //trace(arguments.join("\r"));
        XMLpCounter++;
        } else {
        XMLpCounter++;

        //----------------------------------------------------------------------------------------
        var this.["icon"+XMLpCounter]:Loader = new Loader();
        var this.["iconFileLink"+XMLpCounter]:String = mediaLoc + locXML.location.iconFile[XMLpCounter];
        var this.["iconFile"+XMLpCounter+"Req"]:URLRequest = new URLRequest(iconFileLink[XMLpCounter]);
        ["imageFileLink"+XMLpCounter] = mediaLoc + locXML.location.imageFile[XMLpCounter];
        ["imageFile"+XMLpCounter+"Req"] = new URLRequest(imageFileLink[XMLpCounter]);
        ["locPointMarker"+XMLpCounter] = new PointMarker();
        ["locPointMarker"+XMLpCounter].buttonMode = ["locPointMarker"+XMLpCounter].useHandCursor = true;

        ["icon"+XMLpCounter].load(["iconFile"+XMLpCounter+"Req"], context);
        ["icon"+XMLpCounter].x = -iconHeight/2;
        ["icon"+XMLpCounter].y = -iconWidth/2;

and so on
}

```

ERRORS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ERRORS

```
var ["icon" + XMLpCounter]:Loader = new Loader();//1084: Syntax error: expecting identifier before left bracket. & 1084: Syntax error: expecting identifier before right bracket.
//var iconFileLink1:String;
//var iconFile1Req:URLRequest;
//var imageFileLink1:String;
//var imageFile1Req:URLRequest;
//obtain from XML the icon for map
var ["iconFileLink"+XMLpCounter]:String = mediaLoc + locXML.location.iconFile[XMLpCounter];//1084: Syntax error: expecting identifier before left bracket. & 1084: Syntax error: expecting identifier before right bracket.
var ["iconFile"+XMLpCounter+"Req"]:URLRequest = new URLRequest(iconFileLink[XMLpCounter]);//1084: Syntax error: expecting identifier before plus. & 1084: Syntax error: expecting identifier before left bracket.
//obtain from XML the ad for bubble
["imageFileLink"+XMLpCounter] = mediaLoc + locXML.location.imageFile[XMLpCounter]; //1084: Syntax error: expecting identifier before assign.
["imageFile"+XMLpCounter+"Req"] = new URLRequest(imageFileLink[XMLpCounter]);//1084: Syntax error: expecting identifier before assign.
["locPointMarker"+XMLpCounter] = new PointMarker();//1084: Syntax error: expecting identifier before assign.
["locPointMarker"+XMLpCounter].buttonMode = ["locPointMarker"+XMLpCounter].useHandCursor = true;//1084: Syntax error: expecting identifier before dot.

["icon"+XMLpCounter].load(["iconFile"+XMLpCounter+"Req"], context);//1084: Syntax error: expecting identifier before dot.
["icon"+XMLpCounter].x = -iconHeight/2;//1084: Syntax error: expecting identifier before dot.
["icon"+XMLpCounter].y = -iconWidth/2;//1084: Syntax error: expecting identifier before dot.

```

EDIT~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~EDIT
Everything seems to be working right now except for two issues.
At the last bit of the code it adds event listeners to each marker; when the loop gets to the following lines of code, it throws an error(shown below code):

```
dict["locPointMarker"+i.toString()].addEventListener(MouseEvent.CLICK, ["locPointMarker"+ i.toString()+"_Click"]);
dict["locPointMarker"+i.toString()].addEventListener(MouseEvent.ROLL_OVER, ["locPointMarker"+i.toString()+"_RO"]);

```

I have also tried this code as follows:

```
dict["locPointMarker"+i.toString()].addEventListener(MouseEvent.CLICK, ["locPointMarker_Click"+ i.toString()]);
dict["locPointMarker"+i.toString()].addEventListener(MouseEvent.ROLL_OVER, ["locPointMarker_RO"+i.toString()]);

```

Error #1034: Type Coercion failed: cannot convert []@1488bac1 to Function.

What I would like to do is omit those two last lines and then add the event listeners in a loop at the end. maybe by sending them arguments or something... Is that possible?