PDA

View Full Version : Get to an object's content from an object's event handler



benh
June 25th, 2008, 02:52 PM
Hi there,

I have some code that is intended to get a list of XML file names from a PHP script and then parse the content of the XML files and stick certain data into a big array called "allData":



var allData:Array = new Array();

var remoteFileNames:GetXMLFileNames = new GetXMLFileNames("http://localhost/getVars/getfilenams.php");
remoteFileNames.addEventListener(GetXMLFileNames.G OT_NAMES, getXMLDataFiles);

function getXMLDataFiles(e:Event):void {
for each (var fileName:String in remoteFileNames.fileNames) {
var xmlLoader:XmlLoader = new XmlLoader(fileName);
xmlLoader.addEventListener(XmlLoader.DATA_PARSED, dataParsed);
}
}

function dataParsed(e:Event):void {
trace ("XML data was parsed");
allData.push(???.content); // problem here!
}


(Of course there's also some class files GetXMLFileNames.as and XmlLoader.as that do their stuff) all works well except that I need to get the references to the content property of each object. I guess I do this via the event handler but I'm not sure exactly how? Any one got any ideas?

Many thanks

Ben

Dom_
June 25th, 2008, 02:59 PM
allData.push (e.target.data);
you might need to cast that

benh
June 26th, 2008, 05:15 AM
Thats the fella! Brilliant stuff Dom thank you!