I’ve got an XML menu, followed the squirrel tutorial and modified the code to suit what I was doing (a news page). Now I’m wanting to generate a single random news entry from this XML document, but I can’t work out how to do it at all!!
I’m guessing the answer is to change something in here, but everything I’ve tried hasn’t worked out so far
function CreateMenu(menu_xml) {
// start with the first item in the XML
var items = menu_xml.firstChild.firstChild.childNodes;
for (var i=0; i<items.length; i++) {
// only continue if the type of this item is news
if (items*.attributes.type == "news") {
// create variables for our elements
var date = items*.childNodes[0]; // first child node
var newsTitle = items*.childNodes[1]; // second child node
var moreInfo = items*.childNodes[2]; // third child node
// Create a menu item movieclip in the menuMC instance on the main timeline
// for each item element offsetting each additional further down the screen
var itemMC = menuMC.attachMovie("menu_item","item"+item_count, item_count);
itemMC._y = item_count * item_spacing;
item_count++;
// assign text using nodeValue to get the text from the text nodes
itemMC.date_txt.text = date.firstChild.nodeValue;
itemMC.newsTitle_txt.text = newsTitle.firstChild.nodeValue;
itemMC.mainBtn.title_txt = newsTitle.firstChild.nodeValue;
itemMC.mainBtn.story_txt = moreInfo.firstChild.nodeValue;
// when itemMC is pressent, calls DisplayInfo function
itemMC.mainBtn.onRelease = DisplayInfo;
}
}
}
Any help would be appreciated
Cheers, Chris