From my experiments with checking the progress of loadMovie, the most reliable progress check is as follows:
Assuming you have set up an onEnter
var prevBytesLoaded:Number = undefined;
// setup onEnterFrameBeacon
mx.transitions.OnEnterFrameBeacon.init();
target.loadMovie(url);
MovieClip["addListener"](this);
// check progress
function onEnterFrame()
{
var bytesLoaded = Math.round(_target.getBytesLoaded());
var bytesTotal = Math.round(_target.getBytesTotal());
if (bytesLoaded > 0 && bytesLoaded >= bytesTotal)
{
// Checking to make sure the bytesLoaded is the same as the one reported in
// previous frame is the most reliable way in getting an accurate value of bytesLoaded
if (bytesLoaded != prevBytesLoaded)
{
trace(bytesLoaded + ", " + bytesTotal);
prevBytesLoaded = bytesLoaded;
}
else
{
MovieClip["removeListener"](this);
}
}
}
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home