I see lots of XML menus that perform one type of action, e.g.: open a new URL everytime a menu item is clicked, but I haven’t seen a good example of how to allow for different actions for different menu buttons. In my case I need to load mainly CDATA test with the exception that one menu item will load an image gallery. I could either call a function to create the gallery or I could use loadMovie to import an external SWF. The main problem is how to change the code below so that when
items*.attributes.type == "imageGallery"
I can do something other than assign the text childNode.
function CreateMenu(menu_xml){
var items = menu_xml.firstChild.firstChild.childNodes; // menu -> menuitems -> child nodes array
for (var i=0; i<items.length; i++) {
if (items*.attributes.type == "textDisplay") {
// create variables for our elements
var navlabel = items*.firstChild;
var content = items*.childNodes[1];
}
if (items*.attributes.type == "imageGallery") {
var navlabel = items*.firstChild;
//var content = items*.childNodes[1];
//NEED TO CALL A FUNCTION HERE
}
var item_mc = menu_mc.attachMovie("menu_item","item"+item_count, item_count);
item_mc._y = item_count * item_spacing;
item_count++;
item_mc.menu_txt.text = navlabel.firstChild.nodeValue;
item_mc.content_text = content.firstChild.nodeValue;
// Apply font attributes
item_mc.menu_txt.embedFonts = true;
item_mc.menu_txt.setTextFormat(mainNavText);
// Problem using "DisplayInfo()" syntax or placing within onRelease function
//item_mc.main_btn.onRelease = DisplayInfo;
item_mc.onPress = DisplayInfo;
item_mc.onRelease = function() {
activebtn.menu_txt.textColor = default_color;
// Change selected MC text to selected color
this.menu_txt.textColor = selected_color;
activebtn = this;
};
item_mc.onRollOver = function() {
if (this != activebtn) {
this.menu_txt.textColor = rollover_color;
}
};
item_mc.onRollOut = function() {
if (this != activebtn) {
this.menu_txt.textColor = default_color;
}
};
}
}