Question
Loading XML into dynamic text boxes
I have an XML document and I am trying to load the text from
that doc into corresponding dynamic text boxes in flash. I wanted
to use a loop to do this because I have 30+ textboxes to load text
into and I thought this would be easiest to do. I know that the XML
is being parsed and I can get it into the dynamic text boxes
without the loop so I know the loop I'm trying to use is the
problem. The dynamic text boxes are named "page1box0", "page1box1",
"page1box2", etc. Here is my AS code (and I'm using Flash 8):
//create new xml object
xmlDoc = new XML();
//ignore white space in xml doc
xmlDoc.ignoreWhite = true;
//used this in a loop to ensure that xml doc loaded
xmlDoc.onLoad = function(success) {
if (success) {
//trace(this);
j=0;
while (j <= xmlDoc.firstChild.firstChild.firstChild.childNodes.length) {
currentXML = xmlDoc.firstChild.firstChild.firstChild.childNodes.firstChild.nodeValue;
trace ("currentXML = " + currentXML);
currentBlank = _root["page1box" + j + "_txt"];
trace ("j = " + j);
currentBlank = currentXML;
j++;
}
//trace ("currentXML = " + currentXML);
} else {
trace("xml not loaded");
}
};
//create new xml object
xmlDoc = new XML();
//ignore white space in xml doc
xmlDoc.ignoreWhite = true;
//used this in a loop to ensure that xml doc loaded
xmlDoc.onLoad = function(success) {
if (success) {
//trace(this);
j=0;
while (j <= xmlDoc.firstChild.firstChild.firstChild.childNodes.length) {
currentXML = xmlDoc.firstChild.firstChild.firstChild.childNodes
trace ("currentXML = " + currentXML);
currentBlank = _root["page1box" + j + "_txt"];
trace ("j = " + j);
currentBlank = currentXML;
j++;
}
//trace ("currentXML = " + currentXML);
} else {
trace("xml not loaded");
}
};
