Skip to main content
Inspiring
November 13, 2008
Question

preloader for xml file and stage assets

  • November 13, 2008
  • 2 replies
  • 448 views
I have a Flash app that shows a map with different regions colored depending on values in an external xml file. I also have a simple preloader that I want to appear until all the elements of the app are ready to be displayed. However, when I use the preloader, the results are the same as if I hadn't use it. My map comes up immediately with no colors, there is a pause, and then the colors come in (as calculated from the data in my xml file). Can anyone tell me what I'm doing wrong? Do I have to have code in my xml loader that tells the user what percent of the file is loaded?
This topic has been closed for replies.

2 replies

November 14, 2008
XML files are really small. If that is all you are loading, it should happen instantly, or close to it depending on the size. Also if you are running it on your local machine, it will load very fast unless you simulate the download.

But incase that is not the issue, your code looks incomplete, or just headed down the wrong path. You should be useing a loader class that has a series of events associated with it. Events like "PROGRESS" and "COMPLETE". These events will fire automatically when a file loads, and when a file is done loading. The Enter frame event is not meant to handle loading. I would suggest using a class like BulkLoader to handle all your loading needs.

http://code.google.com/p/bulk-loader/
Laura MSAuthor
Inspiring
November 14, 2008
I have ended up using this code, which works, but may be less elegant:
Colin Holgate
Inspiring
November 13, 2008
Not sure if there's other things wrong with the routine, but one thing to watch for is whether bytesTotal is more than zero. At the very start it may be on zero, and so would equal the bytesLoaded.

Also, you probably should remove the enterframe listener when you do the play().