|
-
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);
}
-
Senior Member
It does sound a bit weird, but i must say that after working with AS3 a good bit, I've seen some weird things... so I'm not too surprised.
In any case, the magnitude of most xml pages amounts to probably that of this page's html-code at most (try viewing this page's source and compare it to your xml file), so I really wouldn't worry about a long loading-time wait period there.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|