Hi,
An attempt to dynamically assign text gathered from XML nodes has me
stumped. I've the text field instances, but am at a loss how to
proceed. Any help would be appreciated.
Code:
//Create XML Object
var aquentDoc:XML = new XML();
aquentDoc.ignoreWhite = true;
//event handler
aquentDoc.onLoad = function(success:Boolean) {
if (!success) {
trace("Failure Loading aquentDoc XML");
return;
}
//validating the xml file
if (this.status != 0) {
trace("This xmlObject is not well-formed: "+this.status);
return;
}
//Error check - xml data okay!
if (this.firstChild.nodeName.toLowerCase() != "aquentdoc") {
trace("Unexpected XML data: "+this.firstChild.nodeName);
return;
}
//Extract header nodes into an array.
var elements_arr = this.firstChild.childNodes;
for (var i = 0; i<elements_arr.length; i++) {
//trace(elements_arr[i]);
if (elements_arr[i].attributes["id"] != null) {
var headers = elements_arr[i].attributes["id"];
//trace(headers);
} else {
var content = elements_arr[i];
//trace(content);
}
}
};
Code:
//Displays the text fields correctly.
function assignText() {
for (var p in this) {
if (this[p] instanceof TextField) {
//Show each field's name
trace("found "+this[p]._name);
}
}
}
Code:
//Failed attempt at assigning text.
//This should be called from inside the onLoad handler.
function assignText() {
for (var p in this) {
if (this[p] instanceof TextField) {
//Show each field's name
trace("found "+this[p]._name);
}
if(this[p]._name == "header01_text){
this[p].text=elements_arr[i].attributes["id"];
}
}
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com