Why are bytes growing in the AS3 preloader?

I am creating a custom preloader for a Flex application and noticed the following behavior: on load, the progress bar goes to 100%, then down, then back up, etc. until the app finishes loading.

When I put a trace in the dowloadprogress listener, I see that while the app is loading, both the loaded bytes and bytesTotal are incremented, but not necessarily at the same time.

the code:

private function onDownloadProgress(event:ProgressEvent):void {
        var loaded:int = event.bytesLoaded;
        var total:int = event.bytesTotal;
        trace(event.target,loaded,total);
        _starfield.progress = loaded/total;
    }

      

Output:

[object Preloader] 134276 134276
[object Preloader] 265348 285007
[object Preloader] 285007 285007
[object Preloader] 678223 1322116
[object Preloader] 809295 1322116
[object Preloader] 1322116 1322116
[object Preloader] 1322116 1322116
[object Preloader] 1387652 1584342
[object Preloader] 1791882 1791882
[object Preloader] 2293133 2293133
[object Preloader] 2362938 2362938
[object Preloader] 2362938 2362938
[object Preloader] 2362938 2362938

      

Why do the bytes change when loaded?

+2


a source to share


2 answers


As the runtime shared libraries are loaded, the total may increase. You can find out a little more about this by reading the source code Preloader

.

Sdk \ frameworks \ projects \ frameworks \ src \ tx \ Preloaders \ Preloader.as

Here are some links to custom preloader samples that handle RSL better than the default.



http://coding.bhirschmann.de/2008/03/20/preloader-for-flex-with-rsl-support/

http://www.leavethatthingalone.com/blog/index.cfm/2009/11/11/Flex4CustomPreloader

+4


a source


or another way would be to split the preloader into 6 stages, with the preloader loading each component and running from 0 to 100% and then incrementing the number or "parts" by loading and displaying that on screen too



0


a source







All Articles