Help with loading XML to textfields

I’m having a problem with loading some xml from an external file into my swf. I’m trying to populate various dynamic text fields with the appropriate value. Eventually this will be used to make it possible to change the language used for them, by changing the xml path.

Right now, everything seems to be in place, but I am not getting the actual value into my text field.

Here is my XML loader:


[COLOR=#000087]stop[/COLOR]();[COLOR=#000087]_global[/COLOR].owner = [COLOR=#000087]this[/COLOR];
[COLOR=#000087]var[/COLOR] xmlPath:[COLOR=#000087]String[/COLOR];
[COLOR=#000087]var[/COLOR] myXML = [COLOR=#000087]new[/COLOR] [COLOR=#000087]XML[/COLOR]();myXML.[COLOR=#000087]ignoreWhite[/COLOR] = [COLOR=#000087]true[/COLOR];
myXML.[COLOR=#000087]onLoad[/COLOR] = [COLOR=#000087]function[/COLOR](success:[COLOR=#000087]Boolean[/COLOR]) {        [COLOR=#000087]if[/COLOR] (success) {
                [COLOR=#000087]var[/COLOR] mytotal:[COLOR=#000087]XMLNode[/COLOR] = myXML.firstChild;
                [COLOR=#000087]var[/COLOR] mytotalcount:[COLOR=#000087]Array[/COLOR] = mytotal.childNodes;
                [COLOR=#000087]_root[/COLOR].mylength = mytotalcount.[COLOR=#000087]length[/COLOR];
                [COLOR=#000087]var[/COLOR] myroot:[COLOR=#000087]XMLNode[/COLOR] = myXML.firstChild.firstChild;
                [COLOR=#000087]for[/COLOR] (i=0; i<=[COLOR=#000087]_root[/COLOR].mylength; i++) {
                        [COLOR=#000087]var[/COLOR] thisTitle = myroot.firstChild.firstChild.nodeValue;
                        [COLOR=#000087]_root[/COLOR].thisTitle = thisTitle;
                        [COLOR=#000087]var[/COLOR] thisText = myroot.firstChild.nextSibling.firstChild.nodeValue;
                        [COLOR=#000087]_root[/COLOR].thisText = thisTitle;
                        [COLOR=#000087]set[/COLOR](("[COLOR=blue]_root.[/COLOR]"+([COLOR=#000087]_root[/COLOR].thisTitle)), myroot.firstChild.nextSibling.firstChild.nodeValue);
                        myroot = myroot.nextSibling;
                }
        } [COLOR=#000087]else[/COLOR] {
                [COLOR=#000087]trace[/COLOR]("[COLOR=blue]xml error[/COLOR]");
        }
};
 
setLanguage = [COLOR=#000087]function[/COLOR] () {
        [COLOR=#878787]// Hardcode path for testing[/COLOR]
        [COLOR=#000087]_root[/COLOR].myLang = "[COLOR=blue]./test.xml[/COLOR]";
        [COLOR=#878787]//[/COLOR]
        xmlPath = [COLOR=#000087]_root[/COLOR].myLang;
        myXML.[COLOR=#000087]load[/COLOR](xmlPath);
};
setLanguage();

Then i have a movieclip with a textfield in it. I name the instance value the same as my name value in the xml:


[COLOR=#000087]onClipEvent[/COLOR] ([COLOR=#000087]load[/COLOR]) {
        myTF.[COLOR=#000087]html[/COLOR] = [COLOR=#000087]true[/COLOR];
        theTitle = [COLOR=#000087]getProperty[/COLOR]([COLOR=#000087]this[/COLOR], [COLOR=#000087]_name[/COLOR]);
        myTF.[COLOR=#000087]htmlText[/COLOR] = [COLOR=#000087]eval[/COLOR]("[COLOR=blue]_root.[/COLOR]"+theTitle);
}

In this case, my clip instance is called test1

Here is my xml file named test.xml:


<?xml version="1.0" encoding="UTF-8" ?><strings>    <string>        <name>test1</name>        <value>Test Item 1</value>    </string>            <string>        <name>test2</name>        <value><![CDATA[<b><font color="#000000" size="12"><p align="center"><br>Test Item 2</font></p></b>]]></value>    </string></strings>

So, when i run my movie, the test1 clip always reads this:

_level0.test1

instead of the value of the xml.

So, I guess my question is where am I going wrong here?

Thanks,

  • DW