I have a class that loads some xml data via php scripting. I am trying to grab the formatted xml (which i have verified is formatted correctly), and stuff it into a number of variables. I try:
package utils.php
{
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
public class DirectoryReader extends EventDispatcher
{
public var fileList:XMLList;
public var totalBytes:int;
private var loader:URLLoader;
public function DirectoryReader(url:String)
{
var urlreq:URLRequest = new URLRequest(url);
trace(url);
urlreq.contentType = "text/xml";
urlreq.method = URLRequestMethod.POST;
loader = new URLLoader(urlreq);
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(urlreq);
}
protected function completeHandler(e:Event):void
{
trace("seems to have worked...");
var loaded:XML = loader.data;
fileList = loaded.child("filelist").attribute("file");
trace("file list: " + fileList);
totalBytes = loaded.child("totalsize");
trace("total size: " + totalBytes);
dispatchEvent(new Event("directoryLoaded"));
}
}
}
Am I doing anything obvious that is wrong? Basically I get an error that the loaded variable cannot be propagated correctly as if there is a type mismatch. FWIW, my class extends EventDispatcher so that I can notify other classes that it has loaded. I am sending in a URL, including php variables ala ? and &.
Thanks, jml