flash actionscript:
I'm not sure what my problem is. I'm parsing an XML file and creating
textfields in AS based on that. I did a trace and found Flash is parsing the
XML and finishing it also gives me the correct text I'm looking for. And when I
check the debugger the correct movieclips are created successfully so I don't
think it's an issue with me creating clips on the same levels. So I'm not sure
why the text will not appear when I test this. Here is my code:
function parseXML(){
trace("parse called");
rootXML = this.firstChild;
child1XML = rootXML.childNodes;
for(var i=0;i<child1XML.length;i++){
child2XML[i] = child1XML[i].childNodes;
var cnn = child1XML[i].nodeName.toLowerCase();
if(cnn == "header"){ // Handle
<HEADER> node
buildMenu(i); // Handle
<HEADER> children
}
}
trace("parse done");
}
function buildMenu(j) {
createEmptyMovieClip("allMenus", 1000);
allMenus.createEmptyMovieClip("menu_"+j, j);
menuItem = eval("allMenus.menu_"+j);
menuItem.createEmptyMovieClip("menuHeader", 1);
menuItem.menuHeader.id = j;
menuItem.menuHeader.menuOpen = false;
menuItem.menuHeader.createEmptyMovieClip("headerText", 2);
menuItem.menuHeader.headerText.createTextField("headerTextItem", 5, 0, 0, 20,
20);
objHeader = eval(menuItem.menuHeader.headerText.headerTextItem);
objHeader.html = true;
objHeader.wordWrap = false;
objHeader.selectable = false;
objHeader.border = false;
objHeader.embedFonts = true;
objHeader.htmlText = child1XML[j].attributes.name; //doesn't seem to work
trace("child1XML:"+ child1XML[j].attributes.name); //returns the correct
text
trace("textWidth:"+objHeader.textWidth); // returns NULL
objHeader._width = objHeader.textWidth + 5;
}
rootXML = new XML(); // Root
"element" XML
child1XML = new Array(); // Level 1
XML
child2XML = new Array(); // Level 2
XML
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = parseXML;
myXML.load("menuEnglish.xml");
stop();