hi guys
i am trying to set up a class to handle my xml (will be instantiated
for each xml file) but i'm running into a slight problem
here is the class so far:
CODE
package
{
//package imports
import flash.events.*;
import flash.net.*;
internal class XMLLoader
{
// class variable declarations
private var xmlDoc:XML;
private var xmlURL:String;
private var xmlLoader:URLLoader;
public function get doc():XML {return xmlDoc;}
// constructor
public function XMLLoader(url:String)
{
xmlURL = url;
var urlRequest:URLRequest = new URLRequest(xmlURL);
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE,
completeListener);
xmlLoader.load(urlRequest);
}
private function completeListener(e:Event):void
{
xmlDoc = new XML(xmlLoader.data);
}
}
}
/CODE
the problem is with timing - from within the XMLLoader() Class i can
wait for the COMPLETE event to reference the xmlDoc but how would i
do that from an instance of the class?
for instance if i do the following from my main class i get a null
object error because it doesn't wait for the data to be loaded before
trying to read it:
CODE
var xmlurl:String = "path/to/xml.xml";
var xmlDoc:XMLLoader = new XMLLoader(xmlurl);
xmlDoc = xmlLoader.doc;
trace (xmlDoc.toXMLString());
/CODE
this would equally apply to an image loader, i guess
thanks in advance
a
Allandt Bik-Elliott
thefieldcomic.com
e [EMAIL PROTECTED]
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders