I am currently working on a menu system where all the MCs are created during run time. Well the short of it is that I am having trouble detecting what MC I am supposed to be moused over. I am using a loop, but the loop run and finishes and uses just the last MC reference.
Below is my code. Any help would be greatly appreciated.
var menu_xml:XML = new XML();
menu_xml.onLoad = startXML;
menu_xml.load("menu.xml");
menu_xml.ignoreWhite = true;
startXML();
function startXML(){
this.createEmptyMovieClip("mainMenu",this.getNextHighestDepth());
xmlLength=menu_xml.firstChild.childNodes;
xPos = 0;
for(i=0;i<xmlLength.length;i++){
clipName = menu_xml.childNodes[0].childNodes*.attributes.cn;
clipText = menu_xml.childNodes[0].childNodes*.attributes.n;
pageLink = menu_xml.childNodes[0].childNodes*.attributes.l;
textName = menu_xml.childNodes[0].childNodes*.attributes.tn;
mainMenu.createEmptyMovieClip(clipName,mainMenu.getNextHighestDepth());
mainMenu[clipName]._x = xPos;
mainMenu[clipName].moveTo(0,0);
mainMenu[clipName].beginFill(0xDD00FF);
mainMenu[clipName].lineTo(100,0);
mainMenu[clipName].lineTo(100,30);
mainMenu[clipName].lineTo(0,30);
mainMenu[clipName].endFill();
mainMenu[clipName].createTextField(textName,mainMenu.getNextHighestDepth(),0,0,50,20);
mainMenu[clipName][textName].html = true;
mainMenu[clipName][textName].htmlText="<a href='" + pageLink + "'>"+clipText+"</a>";
xPos += 150;
overRoll();
outRoll();
}
}
function overRoll(){
mainMenu[clipName].onRollOver = function(){
listLength = menu_xml.childNodes[0].childNodes;
for(var ii=0;ii<listLength.length;ii++){
if(listLength[ii].nodeName == "m"){
listLength2 = menu_xml.childNodes[0].childNodes[ii].childNodes;
tbH = 30;
for(var iii=0;iii<listLength2.length;iii++){
bCat = menu_xml.childNodes[0].childNodes[ii].childNodes[iii].attributes.n;
fieldName = menu_xml.childNodes[0].childNodes[ii].childNodes[iii].attributes.cn;
link = menu_xml.childNodes[0].childNodes[ii].childNodes[iii].attributes.l;
mainMenu[clipName].createTextField(fieldName,200+iii,0,tbH,80,15);
mainMenu[clipName][fieldName].html = true;
mainMenu[clipName][fieldName].htmlText ="<a href='"+ link +"'>" + bCat + "</a>";
tbH+=15;
}
}
}
}
}
function outRoll(){
mainMenu[clipName].onRollOut = function(){
listLength = menu_xml.childNodes[0].childNodes;
for(var ii=0;ii<listLength.length;ii++){
listLength2 = menu_xml.childNodes[0].childNodes[ii].childNodes;
for(var iii=0;iii<listLength2.length;iii++){
fieldName = menu_xml.childNodes[0].childNodes[ii].childNodes[iii].attributes.cn;
mainMenu[clipName][fieldName].removeTextField();
}
}
}
}