Hi,
i am (was) trying to make a xml driven menu. i am using duplicateMovieClip to duplicate a movieclip inside which there is a textfield which gets filled with a title from an array that is loaded from the xml.
that’s all fine. But then i wanted some of these buttons (when pressed) to populate additional submenus using another function using duplicateMovieClip. uh oh, the second i clcik my top buttons, the submenu gets filled, but the top menu disappears!
what do i do?
here’s the code so far
///////////////////////////////////////////
//load XML
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
topNavNames = [];
subNavTrue = [];
nav00 = [];
total = xmlNode.childNodes.length;
for (t=0; t<total; t++) {
topNavNames[t] = xmlNode.childNodes[t].childNodes[0].firstChild.nodeValue;
subNavTrue[t] = xmlNode.childNodes[t].childNodes[1].firstChild.nodeValue;
nav00[t] = xmlNode.childNodes[0].childNodes[2].childNodes[t].firstChild.nodeValue;
}
//populate top menu
loadMenu();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("menu.xml");
////////////////////////////////////////////////////////////////////////////////////
testButton._visible = 0;
function loadMenu() {
for (i=0; i<topNavNames.length; i++) {
gap = 8;
testButton.duplicateMovieClip("topButt"+i, i);
this["topButt"+i].buttName = topNavNames[this.i];
this["topButt"+i].buttNameBox.autoSize = "left";
this["topButt"+i]._width = this["topButt"+i].buttNameBox._width;
if (i>0) {
this["topButt"+i]._x = this["topButt"+(i-1)]._x+this["topButt"+(i-1)]._width+gap;
//button actions
}
this["topButt"+i].i = i;
this["topButt"+i].onPress = function() {
trace(this.i);
if (subNavTrue[this.i] == "1") {
trace("we need a sub-nav");
loadSubMenu(this.i);
} else {
trace("no sub needed");
}
};
}
}
////
subNavButton._visible = 0;
function loadSubMenu(navNum) {
//
//
activeSub = "nav0"+navNum;
maxSubs = 10;
//trace(activeSub);
//trace(nav00[1]);
for (y=0; y<maxSubs; y++) {
var gap = 8;
subNavButton.duplicateMovieClip("subButt"+y, y);
this["subButt"+y].subbuttName = nav00[this.y];
this["subButt"+y].subbuttNameBox.autoSize = "left";
this["subButt"+y]._width = this["subButt"+y].subbuttNameBox._width;
if (y>0) {
this["subButt"+y]._x = this["subButt"+(y-1)]._x+this["subButt"+(y-1)]._width+gap;
//button actions
}
}
}
so is it true that you can only use 1 instance of duplicatemovieclip?
any help is as always greatly appreciated.
kd