GreyEskimo
07-22-2005, 12:04 AM
This is somewhat similar to a thread not 10 posts down (http://www.actionscript.org/forums/showthread.php3?t=79265), but I think the difference is large enough to warrent its own thread:
So, heres the dealy-o. I am building a package in which one of the classes loads in an xml file and does things with the info. My problem is with the loading of the actual document. The constuctor for the class is quite simple, it takes in a string that points to the wanted xml file location, and then the information is to be parsed and used. Something much like this:
class exampleClass {
var xmldoc:XML;
//Default constructor, and such
public function exampleClass(xmlFile:String) {
this.xmldoc = new XML();
this.xmldoc.ignoreWhite = true;
this.xmldoc.load(xmlFile);
//I'd like to check for if the xmldoc has been loaded
//and start to work on it now
}
}
Now, that code snipet works just fine for loading, but I need to operate on the document right after it finishes. I understand that the XML.load() dosn't halt the system, but launches a new thread, so i need a way to have the system halt at that load line in that class until the .load() is done.
I first tried a while loop:
while(!this.xmldoc.loaded){
//nothing
}
but that failed right out. I then tried a the same sort of thing with the .getBytesLoaded/.getsBytesTotal function to, also, no avail.
So thats whats going on. So I pose this question to you:
How can I force the system to wait for the .load function to finish so that I can have code operate on it right away?
Thanks very much in advance,
So, heres the dealy-o. I am building a package in which one of the classes loads in an xml file and does things with the info. My problem is with the loading of the actual document. The constuctor for the class is quite simple, it takes in a string that points to the wanted xml file location, and then the information is to be parsed and used. Something much like this:
class exampleClass {
var xmldoc:XML;
//Default constructor, and such
public function exampleClass(xmlFile:String) {
this.xmldoc = new XML();
this.xmldoc.ignoreWhite = true;
this.xmldoc.load(xmlFile);
//I'd like to check for if the xmldoc has been loaded
//and start to work on it now
}
}
Now, that code snipet works just fine for loading, but I need to operate on the document right after it finishes. I understand that the XML.load() dosn't halt the system, but launches a new thread, so i need a way to have the system halt at that load line in that class until the .load() is done.
I first tried a while loop:
while(!this.xmldoc.loaded){
//nothing
}
but that failed right out. I then tried a the same sort of thing with the .getBytesLoaded/.getsBytesTotal function to, also, no avail.
So thats whats going on. So I pose this question to you:
How can I force the system to wait for the .load function to finish so that I can have code operate on it right away?
Thanks very much in advance,