|
-
Help with ProgressBar loading XML
2 a.m. and my eyes are crusting over...
I've done some quick looking around and have been led to believe this won't work. All I want to do is show the progress bar component while a rather large xml file is loading. The XML loads just fine but it's as if the trace doesn't happen until the load is complete. What am I missing?
Here's what I've got so far. I've got an instance name "progressBar on the stage.
Actionscript Code:
var xmlResults:XML; var xRequest:URLRequest=new URLRequest("detail.xml"); var xmlLoader:URLLoader = new URLLoader(); progressBar.source = xmlLoader; progressBar.mode = ProgressBarMode.POLLED xmlLoader.load(xRequest);
progressBar.addEventListener(ProgressEvent.PROGRESS, progressHandler); progressBar.addEventListener(Event.COMPLETE, progressComplete);
function progressHandler(event:ProgressEvent):void{ trace("Loading"); } function progressComplete(event:Event):void{ trace("Loading complete"); }
As always, thanks!
-
Hi I dont think you should be listening to your progress bar, instead you should be listening to your xmloader...
xmlLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
xmlLoader.addEventListener(Event.COMPLETE, progressComplete);
... give that a bash. thats how i have mine set up.
Tar
Aidan
-
Well that would certainly make sense but the problem persists.
A little more detail, I have the ProgressBar component on my stage with an instance of "progressBar" When I test the movie using the code below, the progressBar vanishes until the XML is all loaded and then the progressBar appears.
And it's weird, the Output window shows all these "Loading" trace statements but only AFTER the XML is all loaded.
Actionscript Code:
var xmlResults:XML; var xRequest:URLRequest=new URLRequest("detail.xml"); var xmlLoader:URLLoader = new URLLoader(); progressBar.source = xmlLoader; //I've tried with POLLED and without. progressBar.mode = ProgressBarMode.POLLED xmlLoader.load(xRequest);
xmlLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler); xmlLoader.addEventListener(Event.COMPLETE, progressComplete);
function progressHandler(event:ProgressEvent):void{ trace("Loading"); } function progressComplete(event:Event):void{ trace("Loading complete"); }
Thanks again.
Last edited by LayneSmith; 03-02-2010 at 10:44 AM.
-
So are you getting in your trace...
loading complete
loading
?? it should be the other way round.
Ive just tried a progress listener in some xml i use and i get "progress made" before "xml load complete" in a trace... which is correct.
This is my code...
PHP Code:
public function pullInXml() { var xmlLoader:URLLoader = new URLLoader; var xmlRequester:URLRequest = new URLRequest("keys.xml"); xmlLoader.addEventListener(ProgressEvent.PROGRESS,progressmade); xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded); xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler); xmlLoader.load(xmlRequester); } public function progressmade(e:ProgressEvent){ trace("progress made"); } public function xmlLoaded(e:Event){ trace("xml load complete") var loader:URLLoader=URLLoader(e.target); keyData = new XML(loader.data); createkeyXmlArray(); }
-
Yeah, sorry. I get it in the correct order. "Loading" a bunch of times then finally "Loading complete". Let me dig into your code a little...
-
Well that's correct then. I don't no what code you use after that, but for each time you hear "loading" from that listener you increment your load bar size or somthing... Caunt help you much after that. You need to look at load bars.
-
Changed it to this, to no avail. The progressBar immediately disappears on test. The output window traces everything, just doesn't display any of it until after it's loaded. Once loaded, the progressBar appears.
Actionscript Code:
var xmlResults:XML; var xmlLoader:URLLoader = new URLLoader(); var xRequest:URLRequest=new URLRequest("detail.xml"); xmlLoader.addEventListener(ProgressEvent.PROGRESS,progressHandler); xmlLoader.addEventListener(Event.COMPLETE,progressComplete); xmlLoader.load(xRequest); function progressHandler(event:ProgressEvent):void{ trace("Loading"); } function progressComplete(event:Event):void{ trace("Loading complete"); }
-
This thread suggests that I won't see the results locally. So I'll upload it and cross my fingers.
http://board.flashkit.com/board/showthread.php?t=798400
-
At least it's moving and counting now. But the preloader stops when the file is loaded and there's a huge gap between when the file has finished loading and when the XML is actually displayed. I have about four more hours to fix this... bleh.
Tags for this Thread
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
|