ForumsProgramming ForumHow do loading bars work

3 3039
GuardianGames
offline
GuardianGames
25 posts
Nomad

Can someone explain how they work why i need one ect, ect?

  • 3 Replies
KhimaeraUK
offline
KhimaeraUK
24 posts
Nomad

There are hoards of tutorials if you google for 'as3 loading bar' or something similar. There are several youtube video tutorials as well.

Briefly how they work, a listener in actionscript listens out for how many bytes of a file (an encapsulated .swf normally in the case of a game) has been loaded [loaderInfo.bytesLoaded], and compares it with the filesize [loaderInfo.bytesTotal] to get a percentage [Math.floor((loaded/total)*100)]. This percentage can be applied to a bar graphic or something [gfk.scaleX = loaded/total].

As for why? Well it's nice to see how far through a load you are. Rather than sitting clueless as to how long you have left to wait. Is there time for a bio break? Isn't there? Can I make a coffee? All these questions answered, by a simple loading bar :P

chahinkerknawi
offline
chahinkerknawi
50 posts
Nomad

well this post answered my question!

Buttersnack
offline
Buttersnack
332 posts
Peasant

Simply, a loading bar checks how much is loaded, converts it to a percent, and scales the loading bar along with that percent. When it hits 100%, it is done loading.

Showing 1-3 of 3