I'd use the MovieClipLoader because it's got better event handling when you'd like to assign traits to a MovieClip (or image in this case) after it's loaded.
This code is not tested. Nor is this code complete! It's just to give you the idea. You'll notice some comments in there where I'm telling you that you'll have to layout your images yourself. That is to say you're going to have to account for the sizes of your images and adjust each one's _x and _y after it's loaded.
Another thing, this isn't going to work very well when you CTRL + ENTER to test in the Flash IDE because it's using root relative urls for your images and links. Since the Flash IDE isn't running on a web server, it won't be able to find your images! You may want to use a special test XML file while debugging in the Flash IDE.
Also, be sure to have a root node in your XML. It's just plain bad XML to have no root node.
XML
<?xml version="1.0" encoding="utf-8"?>
<root>
<myImage>
<imagePath>/flash/image1.jpg</imagePath>
<imageurl>/flash/image1.html</imageurl>
</myImage>
<myImage>
<imagePath>/flash/image2.jpg</imagePath>
<imageurl>/flash/image2.html</imageurl>
</myImage>
<myImage>
<imagePath>/flash/image3.jpg</imagePath>
<imageurl>/flash/image3.html</imageurl>
</myImage>
</root>
Actionscript (frame 1):
var xmlData:XML = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = function(loaded) {
if (loaded) {
for(var i = 0; i < this.firstChild.childNodes.length; i++) {
var mc:MovieClip = _root.createEmptyMovieClip("item" + i, _root.getNextHighestDepth());
var node:XMLNode = this.firstChild.childNodes[i];
loadMovieClip(mc, node);
}
} else {
trace("file not loaded!");
}
};
xmlData.load("/flash/languages.xml");
function loadMovieClip(mc:MovieClip, node:XMLNode) {
var loadListener:Object = new Object();
loadListener.onLoadInit = function(target:MovieClip, httpStatus:Number) {
//Be sure to do your positioning here!!! You probably
// don't want to stack them on top of each other.
// I didn't do that so you'll have to do it yourself.
target._x = 30;
target._y = 30;
var url = node.childNodes[1].firstChild.nodeValue;
target.onMouseUp = function() {
getURL(url);
}
//be sure to do positioning of your text field too.
var txt:TextField = _root.createTextField(target._name + "_text", _root.getNextHighestDepth(), 30, 100, 100, 20);
txt.text = url;
txt.type = "static";
txt.onMouseUp = function() {
getURL(url);
}
}
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(loadListener);
mcl.loadClip(node.childNodes[0].firstChild.nodeValue, mc);
}
I hope that helps.