hi dave. thanks for your response. i understand the problem. but i am
now resetting currentWeight to 0 directly after i test what percentage
i'm at and i'm still getting skewed values:
here is my code:
mclListener.onLoadProgress = function( targetMC, loadedBytes, totalBytes )
{
currentWeight += loadedBytes;
var currentPercentage = Math.floor( ( currentWeight /
totalWeight ) * 100 );
if( currentPercentage % 10 == 0 )
{
trace( "another 10% completed" );
}
switch( String( currentPercentage ) )
{
case "10" :
trace( "10% has loaded..." );
break;
case "20" :
trace( "20% has loaded..." );
break;
// etc...etc....);
}
currentWeight = 0;
};
when i test each external swf individually, i still get skewed
results, for example:
swf1 = 312KB = 316,020 bytes // the trace value is 353,483
// NOW ADD
swf2 987K = 1330176 byets // the trace value is 1079498
// THEN ADD THIS
swf3 2.6MB = 4056473 bytes// the trace value is 2819958
i just can't seem to get this right. is there a better way i can approach this?
thanks again for your help. -- matt.
On 11/18/05, David Rorex <[EMAIL PROTECTED]> wrote:
> 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
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders