Displaying XML data in dynamic text fields with AS3
Hi Everyone,
I am trying to display XML data into dynamic text fields on my timeline.
So I am working on my personal site, justinbrinkerhoff.info (the swf on there is old, and I'm updating it now). I am working the fla file, and am reading data from an xml file. The problem is, the syntax I am using is not showing the values inside the dynamic text field, and upon exporting the swf.
So here is what I have.
The fla/swf are both named jbDOTinfo
I am working within a keyframe of which I created to show my portfolio; Flash, *ML, PHP, Rails, etc... Well I am working in frame 27, which I created to house the "page" so to speak for my PHP portfolio page.
Within frame 27, I have the main content on one layer, and the embedded actionscript on another layer. Now, on the main layer, the dynamic text field instance name is phpInput. My XML filename is php.xml, located in a child directory named xml (xml/php.xml).
Here is my AS3 syntax:
Code:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadPHPxml);
xmlLoader.load(new URLRequest("xml/php.xml"));
function LoadPHPxml(e:Event):void {
xmlData = new XML(e.target.data);
parsePortfolioPHP(xmlData);
}
function parsePortfolioPHP(portfolioPhpInput:XML):void
{
trace(portfolioPhpInput.item);
var title = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
// url = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
phpInput.text = title;
}
I can find my way around fairly well with ActionScript, but this is hurting my head. When I export the SWF file, and I navigate my way to frame 27 through the SWF, I get this output:
Code:
TypeError: Error #1010: A term is undefined and has no properties.
at jbDOTinfo_fla::MainTimeline/parsePortfolioPHP()
at jbDOTinfo_fla::MainTimeline/LoadPHPxml()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
I know its something simple, I just cant think what it is. Everything I've tried so far gets me the same or similar results.
If anyone could help clear this up for me, it'd be greatly appreciated.