A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: preloading XML- bytesTotal

  1. #1
    will i ever get it?
    Join Date
    Feb 2004
    Posts
    707

    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:URLLoaderURLLoader(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);
            } 

  2. #2
    Senior Member ozmic66's Avatar
    Join Date
    Oct 2005
    Posts
    472
    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.
    Pixelwave Flash-based iPhone framework
    iPhone Games: Flyloop | Freedom Run

    Twitter: Oztune

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center