I'll be brief. I have an XML file with text data and I have a dynamic text field called "txt" located within a movie clip called "mc". I want to be able to load various text data from my XML file into that same text field. I made a function that creates an XML object with one argument. That argument simply passes along what nodeValue to load into the text field. Sounds simple enough right? When I run code below, it comes up as "undefined".
Code:function loadXml(theData) { var xmlObj = new XML(); xmlObj.ignoreWhite = true; xmlObj.load("xml/about.xml"); xmlObj.onLoad = function() { mc.txt.autoSize = true; mc.txt.text = eval(theData); //loading the result of the argument into the text field. } } loadXml("xmlObj.firstChild.childNodes[0].firstChild.nodeValue"); // Loading function and passing the XML text location as an argument.
However, down below when I don't use arguments and just put the XML location directly into function, it loads the text perfectly.
I can't figure out why I can't get it to work with the function argument which will give me more flexibility in what I want to load. Any ideas?Code:function loadXml() { var xmlObj = new XML(); xmlObj.ignoreWhite = true; xmlObj.load("xml/about.xml"); xmlObj.onLoad = function() { mc.txt.autoSize = true; mc.txt.text = xmlObj.firstChild.childNodes[0].firstChild.nodeValue; //loading the same XML data directly into the text field } } loadXml();




Reply With Quote
