[Flash8/Actionscript]Help needed with Kirupa tutorial!

Hello there, I have been working through this tutorial:

http://www.kirupa.com/web/xml/examples/squirrelfinder.htm

and I have got a little stuck.

I was working/reading through the examples and trying to apply it to my own little project.
What I need for my own project is to create something with works along the lines of this logic:

XML gallery
1.Load an xml file
2.Navigate the XML object with actionscript.
3. Pull key/value pieces of data (an image path and a url) to be output to the flash movie later on.
4.For every key/value pair create a new flash button on the fly.
5.When the button is clicked load an associated image in the Flash movie.
6.When the image is loaded in the flash movie and is clicked trigger the url.

I was using the tutorial as it seemed similiar to what I need, and found it quite tricky (as a flash n00b) to even navigate the xml object. But I think I have reached stage 3 in my list.

The code I am alittle stuck with is from this and is highlighted in bold:


function CreateMenu(menu_xml){

var items = menu_xml.firstChild.firstChild.childNodes;
for (var i=0; i<items.length; i++) {

if (items*.attributes.type == "squirrel") {

var species = items*.firstChild;
var location = items*.childNodes[1];
 
**var item_mc = menu_mc.attachMovie("menu_item","item"+item_count, item_count);
item_mc._y = item_count * item_spacing;
item_count++;
 
item_mc.species_txt.text = species.firstChild.nodeValue;
item_mc.main_btn.location_text = location.firstChild.nodeValue;
item_mc.main_btn.onRelease = DisplayInfo;**

}

}

}


My xml file


<root>
    <image>
        <path>image1.gif</path>
        <url>http://www.google.co.uk/</url>
    </image>
    <image>
        <path>image2.gif</path>
        <url>http://www.yahoo.co.uk/</url>
    </image>
    <image>
        <path>image3.gif</path>
        <url>http://www.hotmail.co.uk/</url>
    </image>
</root>

Actionscript I adapted:


//Create new instance of XML for Flash to parse
var my_xml = new XML();
//Remove ****espace from xml file
my_xml.ignoreWhite = true;
//Load XML

my_xml.onLoad = function(success){
//If xml loaded
if (success){
    CreateMenu(this);
    }
}

var item_spacing = 28;
var item_count = 0;

//This function navigates the xml actionscript object
function CreateMenu(menu_xml){
        //Target the nodes you need and save them to the variable items
        var items = menu_xml.firstChild.childNodes;
        //Loop through each node
        for (var i=0; i<items.length; i++) {
        //Target the values of each node and resave to a new variable
        var imagepath = items*.firstChild;
        var imagepath_nodeValue = imagepath.firstChild;
        var url = items*.childNodes[1];
        var url_nodeValue = url.firstChild;
        trace(imagepath_nodeValue);
        trace(url_nodeValue);

        
        }
    }

//Path to xml file
my_xml.load("images.xml");

I am stuck on how to

  1. dynamically create the button on the fly depending on how many key value pairs I have.
  2. How to assign the key/value pairs to the buttons.

I have read through the tutorial, but I am a little confused and don’t fully understand the explanation of the button creation part. Also, I don’t think I need the DisplayInfo bit.

Could anyone help?

Cheers!