preloading XML- bytesTotal
hi guys...of the subject of display objects for a bit here. i am preloading some XML data from a dynamic source. I have an eventListerner that does well counting the bytesLoaded, but gives 0 always for the bytesTotal . After reading the documentation, i find
Code:
This property contains 0 while the load operation is in progress and is populated when the operation is complete.
yikes, com'n...that can't be, can it? so how can i preload XML so the user knows it is well on the way. Granted, this XML file is not super-HUGE, but there is a lag moment that justifies a preloader of sorts
PHP Code:
//inside my package/class.....
public function loadURL(_url:String){
urlR=new URLRequest(_url);
urlL=new URLLoader();
urlL.load(urlR);
urlL.addEventListener(ProgressEvent.PROGRESS,loading)
urlL.addEventListener(Event.COMPLETE,loaded);
}
private function loading(pe:ProgressEvent){
var track:URLLoader= URLLoader(pe.currentTarget);
var bl=track.bytesLoaded;
var bt=track.bytesTotal;
var percent:Number=Math.round((bt/bl)*100);
}
private function loaded(ev:Event){
xml=XML(ev.currentTarget.data);
}