On 11/18/05, Matt Ganz <[EMAIL PROTECTED]> wrote:
> hi.
>
> i'm using the MovieClipLoader class to load a few swfs that are
> defined in an array a la:
>
>
> var totalWeight = 41079759; // total weight in bytes (3.9MB)
> var currentWeight = 0;
>
> var mainArray:Array = new Array( { path: "movie1.swf", id:
> "movie1_mc", depth: 1 },
>                                                                         { 
> path: "movie2.swf", id: "movie2_mc", depth: 2 },
>                                                                         { 
> path: "movie3.swf", id: "movie3_mc", depth: 3 });
>
> for( i:Number=0; i<mainArray.length; i++ )
> {
>                 _root.loadClip( mainArray[i].path, this.createEmptyMovieClip(
> mainArray[i].id,        mainSwfArray[i].depth ) );
> }
>
> what i want to do is read how much is loaded of the total weight ( the
> sum of all swfs ) and target my preloader for every 10%. i assume the
> best place to read the loaded bytes is in the onLoadProgress handler
> for MCL, a la:
>
> mainMclListener.onLoadProgress = function( targetMC, loadedBytes, totalBytes )
> {
>         currentWeight += loadedBytes;
>         var currentPercentage = Math.floor( ( loadedBytes / totalWeight ) * 
> 100 );
> }
>
> the 3 swfs weight approximately 3.9 megabytes but when i trace out the
> value of "currentWeight", i get this value:
>
> 407,970,619.....but this equals 389 megabytes, not 3.9. what am i
> doing wrong here?
>
> thanks for any tips. -- matt.

It's because you are continuously adding to 'currentWeight', and never
resetting it to 0.

For example, in the case of loading just one file:

if my file was 1000 bytes, and the load progress was:
200 bytes finished...
300 bytes finished..
500 bytes finished...
700 bytes finished...
1000 bytes finished...all done!

then obviously, just adding those numbers together would be incorrect,
it would give me 2700, which means nothing.

-David R
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to