I’m working on a navigation bar based off of senocular’s amazing XML drop-down menu tutorial. I’ve managed to make the menu horizontal, and changed the boxes from rectangles to squares. All of that works fine.
Now I need to figure out how to add an image to the inside of each element, and I can’t figure out how to do that. I’ve added
curr_item.image = curr_node.attributes.image;
to the AS, and added an ‘image’ movieclip inside my menuitem, but that doesn’t appear to work.
Here’s my complete actionscript:
GenerateMenu = function(container, name, x, y, depth, node_xml) {
var curr_node;
var curr_item;
var curr_menu = container.createEmptyMovieClip(name, depth);
for (var i=0; i<node_xml.childNodes.length; i++) {
curr_item = curr_menu.attachMovie("menuitem", "item"+i+"_mc", i);
curr_item._x = x + i*curr_item._width*1;
curr_item._y = y;
curr_item.trackAsMenu = true;
curr_node = node_xml.childNodes*;
curr_item.action = curr_node.attributes.action;
curr_item.variables = curr_node.attributes.variables;
curr_item.name.text = curr_node.attributes.name;
curr_item.image = curr_node.attributes.image;
curr_item.onRelease = function() {
Actions[this.action](this.variables);
};
}
};
Createmainmenu = function(x, y, depth, navXML) {
GenerateMenu(this, "navmenu_mc", x, y, depth, NavXML.firstChild);
};
Actions = Object();
Actions.gotoURL = function(urlVar){
getURL(urlVar, "_self");
};
navXML = new XML();
navXML.ignoreWhite = true;
navXML.onLoad = function(ok) {
if (ok){
Createmainmenu(50, 280, 0, this);
}
};
navXML.load("navigation.xml");
And here’s my XML:
<navigation name="links">
<item name="About Us" action="gotoURL" variables="http://www.google.com" image="image0.jpg" />
<item name="Featured" action="gotoURL" variables="featured.html" image="image1.jpg" />
<item name="Search" action="gotoURL" variables="search.html" image="image3.jpg" />
<item name="Buyers" action="gotoURL" variables="reseller.html" image="image4.jpg" />
<item name="Communities" action="gotoURL" variables="communities.html" image="image5.jpg" />
<item name="Contact" action="gotoURL" variables="contact.html" image="image6.jpg" />
</navigation>
And attached at the bottom is the .fla. Please help!