hi.
thanks for your responses. i tried out the first idea and it works 98%
of the time. here's the code ( notice that i'm doing this in the
'onLoadProgress' handler of a MovieClipLoader instance ):
mclListener.onLoadProgress = function( targetMC, loadedBytes, totalBytes )
{
var currentPercentage = Math.floor( ( loadedBytes / totalWeight ) * 100
);
// for each increase in 10%, move to next frame
if( currentPercentage % 10 == 0 )
{
_level0.main_mc.nextFrame();
}
};
the other 2% of the time it either:
A.) doesn't reach the last frame of main_mc
B.) it does reach the last frame of main_mc but seems to get stuck there.
i then tried the 2nd method like this:
var oldPercentage = 0;
mainMclListener.onLoadProgress = function( targetMC, loadedBytes, totalBytes )
{
var currentPercentage = Math.floor( ( loadedBytes / totalWeight ) * 100
);
if( Math.floor( currentPercentage / 10 ) != oldPercentage )
{
oldPercentage = Math.floor( currentPercentage / 10 );
_level0.main_mc.nextFrame();
}
};
and in this case, the nextFrame() gets called NOT with each new 10%
loaded, but one immediately after the other. i can't quite figure out
what is going wrong. can anyone see the problem?
thanks for lending a hand. -- matt.
On 11/17/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> What if percentage doesn't increase with 1 every frame? That if
> statement will then miss sometimes.
>
> You could do something like:
>
>
> var oldPercentage = 0;
>
> //then in update loop
> if (Math.floor(percentage/10) != oldPercentage) {
> trace("Another 10% loaded");
> oldPercentage = Math.floor(percentage/10);
> }
>
>
> Not the nicest solution but at least it works.
>
> /Andreas
>
>
> Adrian Lynch wrote:
> > How about...
> >
> > if ( percentage % 10 == 0 ) {
> > trace("Another 10% loaded");
> > }
> >
> > Ade
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] Behalf Of Matt Ganz
> > Sent: 16 November 2005 21:31
> > To: Flashcoders mailing list
> > Subject: [Flashcoders] tracing every 10% of loading files
> >
> >
> > hi.
> >
> > hopefully this question isn't too newbie.
> >
> > i'm loading a bunch of external swfs and i am trying to determine what
> > percentage of 'totalWeight' is 'currentWeight'. here's my equation:
> >
> > var percentage = (currentWeight/totalWeight) * 100;
> >
> > i believe that's fine. but my question is how can i express the following:
> >
> > "for every increase of 10%, up to 100%...." // trace( "another 10% loaded" )
> >
> > thanks. -- matt.
> >
> > _______________________________________________
> > Flashcoders mailing list
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> >
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders