I am having a hard time trying to create a sub-menu using xml. The main menu works but the sub-menu is not being populated. Here is the AS and the XML
Object.registerClass ("item1",src.button);
Object.registerClass ("item2",src.button);
Object.registerClass ("item3",src.button);
Object.registerClass ("item4",src.button);
import src.button;
var item1:button;
var item2:button;
var item3:button;
var item4:button;
var space:Number = 5;
var TotalButtons:Number = 5;
function loadXML (loaded)
{
if (loaded) {
xmlNode = this.firstChild;
GenerateMenu(xmlNode);
} else {
trace ("file not loaded!");
}
}
xmlData = new XML ();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load ("src/menu.xml");
function ShowSubNav(p) {
this.mcSubNav.txtField.htmlText = "";
for (b = p; b < totalSubNav; b++) {
trace(mcSubNav.txtField.htmlText );
}
};
GenerateMenu = function(node_xml) {
var curr_node;
var curr_item = [];
var totalNodes = node_xml.childNodes.length;
for (var i=0; i<totalNodes; i++) {
curr_node = node_xml.childNodes*;
curr_item.name = curr_node.attributes.name;
curr_item.subLabel = curr_node.attributes.subLabel;
curr_item.link = curr_node.attributes.link;
this["item" + i].Labels = curr_item.name;
this["item" + i].SubLabels = curr_item.subLabel;
subNav = node_xml.childNodes*;
totalSubNav = subNav.childNodes.length;
trace(subNav.childNodes*.nodeName)
this["item" + i].onRollOver = curr_item.onDragOver = function(){
this.over();
if (subNav.nodeName == "item")
{
for (j=0;j<totalSubNav;j++)
{
mcSubNav.txtField.htmlText += "<FONT><u><a href='http://"+curr_item.sublink+"'target='_blank'>"+curr_item.name+"</a></u></FONT> - ";
}
}else{
mcSubNav.txtField.htmlText = "";
curr_item.onRollOver = curr_item.onDragOver = function(){
};
}
}
}
};
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<menu>
<menuItem name="home" subLabel="go to start" link="index.html">
</menuItem>
<menuItem name="about" subLabel="who we are" link="index.html">
<item name="About Link1" link="http://www.msn.com"/>
<item name="About Link1" link="http://www.msn.com"/>
</menuItem>
<menuItem name="services" subLabel="what we do" link="index.html">
<item name="Services Link1" link="http://www.yahoo.com"/>
</menuItem>
<menuItem name="solutions" subLabel="solving problems" link="index.html">
<item name="Solutions Link1" link="http://www.apple.com"/>
</menuItem>
<menuItem name="contacts" subLabel="phone, or email" link="index.html">
<item name="Contact Link1" link="http://www.google.com"/>
</menuItem>
</menu>