Is there a way to load a file and waiting for the event listener with out continuing executing other code.
I tried using a while loop with a flag that is set by the on Complete in order to exit the wait loop.
This generates a timeout error.
private var loaded:Boolean = false;
function SpriteLoader(filepath:String){
trace(“Attempting to Load File:” + filepath);
FileLoader = new Loader();
var FileRequest = new URLRequest(filepath);
FileLoader.contentLoaderInfo.addEventListener(Event.OPEN, openedListener);
FileLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener);
FileLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
FileLoader.load(FileRequest);
wait();
}
//--------------------------------------------
private function wait():void{
while(loaded == false){
}
}
//on complete
//--------------------------------------------------
private function completeListener(event:Event):void{
trace(“SWF Loading complete”);
loaded = true;
}