When I click any text, it will display the next level of XML. But it will only display the very first child and the OnRollOver, onRollOut, and OnPress will not work. What am I missing?
Here is the ABC.xml file with additional items.
<automobile><ford><mustang/><explorer/></ford><chevrolet><camaro/></chevrolet><pontiac><firebird/></pontiac></automobile>
Open Flash MX and put this ActionScript in the first frame.
[AS]
XMLdb = new XML();
XMLdb.load(“ABC.xml”);
XMLdb.onLoad = xmlLoad;
XMLdb.ignoreWhite = true;
function xmlLoad(ok){
if(ok==true){
// parse the XML without the childNodes array at all
var level1Height = 125;
var level2Height = 250;
var level1_xml = this.firstChild.firstChild;
var j = 1;
var i = 1;
while (level1_xml != null){
var level1_mc = _root.createEmptyMovieClip(“level1”+i, i+100);
level1_mc.createTextField(“level1Text”, 100, 85, 0, 1, 1);
level1_mc.level1Name = level1_xml.nodeName;
level1_mc.level1Text.autoSize = “center”;
level1_mc.level1Text.background = false;
level1_mc.level1Text.selectable = false;
level1_mc.level1Text.html = true;
level1_mc.level1Text.htmlText = “<font size=‘20’><b>”+level1_mc.level1Name+"</b></font>";
level1_mc._x = 5;
level1_mc._y = level1Height+(level1_mc._heighti1.5);
level1_mc.onRollOver = myOver;
level1_mc.onRollOut = myOut;
level1_mc.onPress = myPress;
level1_mc.onRelease = myRelease;
level1_xml = level1_xml.nextSibling;
i++;
}
}
}
function myOver(){
this.level1Text.background = true;
this.level1Text.backgroundColor = 0x9999FF;
this.level1Text.textColor = 0x000000;
}
function myOut(){
this.level1Text.background = false;
}
function myPress(){
this.level1Text.backgroundColor = 0x0000FF;
this.level1Text.textColor = 0xFFFFFF;
}
function myRelease(){
this.level1Text.background = false;
this.level1Text.textColor = 0x000000;
var level2_xml = XMLdb.firstChild.firstChild.firstChild;
while (level2_xml != null){
var level2_mc = _root.createEmptyMovieClip(“level2”+j, j+200);
level2_mc.createTextField(“level2Text”, 200, 85, 0, 1, 1);
level2_mc.level2Name = level2_xml.nodeName;
level2_mc.level2Text.autoSize = “center”;
level2_mc.level2Text.background = false;
level2_mc.level2Text.selectable = false;
level2_mc.level2Text.html = true;
level2_mc.level2Text.htmlText = “<font size=‘18’><b>”+level2_mc.level2Name+"</b></font>";
level2_mc._x = 150;
level2_mc._y = level2Height+(level2_mc._heightj1.5);
level2_mc.onRollOver = myOver;
level2_mc.onRollOut = myOut;
level2_mc.onPress = myPress;
level2_xml = level2_xml.nextSibling;
j++;
}
}
[/AS]