# Problems with Dynamic Buttons, Text and XML

**URL:** <https://forum.kirupa.com/t/problems-with-dynamic-buttons-text-and-xml/35299>\
**Category:** flash\
**Created:** [November 12, 2003, 2:28pm UTC](https://forum.kirupa.com/t/problems-with-dynamic-buttons-text-and-xml/35299 "2003-11-12T14:28:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![milhat](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@milhat](https://forum.kirupa.com/u/milhat)\
**Post date:** [November 12, 2003, 2:28pm UTC](https://forum.kirupa.com/t/problems-with-dynamic-buttons-text-and-xml/35299/1 "2003-11-12T14:28:32Z")

</div>

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.\_height_i_1.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.\_height_j_1.5);  
level2\_mc.onRollOver = myOver;  
level2\_mc.onRollOut = myOut;  
level2\_mc.onPress = myPress;  
level2\_xml = level2\_xml.nextSibling;  
j++;  
}  
}  
[/AS]
