Assigning URL to MCs via XML

So I’m trying to get better at AS3, and am working on a file that uses XML. I’ve got some of it to work, but can’t wrap my head around this. My XML looks kinda like this:


with more than one “piece” obviously.

I can get the XML and do stuff with the images (put them all on the stage with a for loop). Next I want to make the images link to the URLs, but I can’t figure out how to assign the corresponding variable to the movieclips.

I load the XML and run my for loop:

function xmlLoaded(e:Event):void {
	var loadedxml:XML = new XML(;
	for (var i:uint=0; i<loadedxml.piece.length(); i++) 
		var pieceholder:MovieClip = new MovieClip();
		pieceholder.buttonMode = true;
		// how to get just the URL we need? 
		**linky =*;**
		var pieceloader = new Loader();
		var pictURLReq:URLRequest = new URLRequest(loadedxml.piece.image.text()*);
		pieceloader.addEventListener(MouseEvent.MOUSE_DOWN, linkygo);

and have a function for the link click:

function linkygo(e:MouseEvent):void
	var strURL:URLRequest = new URLRequest(linky);
	navigateToURL(strURL, "_blank");

and what happens? all the buttons go to the same link, the last one from my XML.

how can I make the buttons go to the correct, corresponding URL?