Folks, why is the following trace() showing null?
public class DataXML {
private var _xml:XMLList;
private var loader:URLLoader;
public function DataXML() {
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest("test.xml"));
}
private function onComplete(e:Event):void {
_xml = new XMLList(loader.data);
/* this works */
trace (_xml);
}
public function get XMLData():XMLList {
return _xml;
}
}
public class DataTest extends Sprite {
private var dataXML:DataXML = new DataXML();
public function DataTest() {
/* this says null */
trace (dataXML.XMLData);
}
}
I can assign regular private/public string variables like “test” and can use getters just fine on the public properties, however, I’m suspecting it’s something with the onComplete()'s closing that removes the XML data from memory, as I tried a simple string assignment to a private variable within onComplete() and returned it through a public getter property, but it returned null as well.
any ideas please let me know!
n.