Hello can anyone help me with my problem… i am trying to load an xml file in a dynamically loaded textfield according to the required text… but i was stuck in a problem that it seems that the AS only creates the last textfield and set the value to it so the first one is not shown… or maybe i have done some wrong code… any ideas?
here is my AS code
this.createTextField("txtField1",5,50,100,50,50);
this.createTextField("txtField2",5,50*2,200,50,50);
function loadXML(loaded) {
numberOfXMLFields = 2;
if (loaded) {
for (i=0; i<(this.firstChild.childNodes.length); i++) {
_root.inventor = this.childNodes[0].childNodes*.firstChild;
switch (i) {
case 0 :
{
trace("inventor : "+_root.inventor);
txtField1.text = _root.inventor;
trace("iteration number : "+i+" text "+txtField1.text);
txtField1.type = "dynamic";
txtField1.autoSize = "center";
txtField1.multiline = true;
txtField1.selectable = false;
txtField1.setTextFormat(my_fmt);
break;
};
case 1 :
{
//_root.inventor = this.childNodes[0].childNodes*.firstChild;
txtField2.text = _root.inventor;
trace("iteration number : "+i+" text "+txtField2.text);
txtField2.type = "dynamic";
txtField2.autoSize = "center";
txtField2.multiline = true;
txtField2.selectable = false;
txtField2.setTextFormat(my_fmt);
break;
}
}
};
} else {
content = "file not loaded!";
}
}
//XML loading
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("inventors.xml");
//Text Formating Style
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0x00FF00;
my_fmt.size = 8;
and here is my XML file contents…
<inventors2>
<name>Thomas Edison</name>
<comment>Inventor of many things such as the incandescent lightbulb.</comment>
<name>Doug Engelbart</name>
<comment>Invented the mouse at the Stanford Research Institute</comment>
<name>Thomas Edison</name>
<comment>Inventor of many things such as the incandescent lightbulb.</comment>
</inventors2>
as you see the first trace comes with undefined … any ideas why?
thanks in advance…