Hi,
From the succinct tutorial by Senocular, an “Introduction to XML in Flash”, I’ve the following novice question. In the code below, is it correct that the XML object is passed to CreateMenu, becoming menu_xml?
//counts menu items as they are added from XML.
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:XMLNode = items*.firstChild;
var location:XMLNode = items*.childNodes[1];
var item_mc:MovieClip = 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;
}
}
}
//Manage XML
//create new XML object instance, remembering to ignore white space
var squirrel_xml:XML = new XML();
squirrel_xml.ignoreWhite = true;
//define an onLoad to create our location menu when the XML has successfully loaded.
squirrel_xml.onLoad = function(success) {
if (success) {
CreateMenu(this);
} else {
trace("Error Loading XML file");
}
//no success? trace error
};
//load the xml file
squirrel_xml.load("squirrel_finder.xml");