Accessing XML data from a different class
Hi all,
I have an xml class that loads xml data, I need to access the data from another class. I have imported the xml classinto the new class and created a new instance of it. However when I try to access the xml data it is coming back as null. I understand this is almost certainly because when it is called the xml data hasn't completed it's load. How can I get round this?
xml class:
package {
import flash.xml.*;
import flash.events.*;
import flash.net.*
import flash.display.*
public class xml extends MovieClip
{
public var xmlRequest:URLRequest;
public var xmlLoader:URLLoader;
public var xmlImages:XML;
public function xml()
{
xmlRequest = new URLRequest("images.xml");
xmlLoader = new URLLoader(xmlRequest)
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
xmlLoader.load(xmlRequest);
}
private function xmlLoaded(event:Event):void
{
trace(xmlLoader.data);
xmlImages = new XML(xmlLoader.data);
}
}
}
Thanks in advance