LoadUtil
Kind of class:  class 

Inherits from:  none 
Version:  02/10/07 
Author:  Aaron Clinger, Mike Creighton 
Classpath:  org.casalib.util.LoadUtil 
File last modified:  Monday, 01 December 2008, 13:34:40 
Summary
Class methods
 getPercentLoaded (loadTarget:Object) : Percent
 Calculates the percent loaded.
 calculateBps (bytesLoaded:Number, startTime:Number, elapsedTime:Number) : Number
 Calculates the load speed in bytes per second (Bps).
 calculateKBps (bytesLoaded:Number, startTime:Number, elapsedTime:Number) : Number
 Calculates the load speed in KBps.
 calculateKbps (bytesLoaded:Number, startTime:Number, elapsedTime:Number) : Number
 Calculates the load speed in kbps.
 calculateBuffer (bytesLoaded:Number, bytesTotal:Number, startTime:Number, elapsedTime:Number, lengthInSeconds:Number) : Object
 Calculates the time and percentage until movie/animation has buffered.
Class methods
calculateBps
static function calculateBps (
bytesLoaded:Number,
startTime:Number,
elapsedTime:Number) : Number
Calculates the load speed in bytes per second (Bps).
Parameters:
bytesLoaded:
Number of bytes that have loaded between
startTime
and elapsedTime
.startTime :
Time in milliseconds when the load started. Can be
0
.elapsedTime:
Time in milliseconds since the load started or time when load completed.
Returns:
 bytes per second.
Usage note:
 This gets BYTES per second, not bits per second.
calculateBuffer
static function calculateBuffer (
bytesLoaded:Number,
bytesTotal:Number,
startTime:Number,
elapsedTime:Number,
lengthInSeconds:Number) : Object
Calculates the time and percentage until movie/animation has buffered.
Parameters:
bytesLoaded :
Number of bytes that have loaded between
startTime
and elapsedTime
.bytesTotal :
Number of bytes total to be loaded.
startTime :
Time in milliseconds when the load started. Can be
0
.elapsedTime :
The current time in milliseconds or time when load completed.
lengthInSeconds:
Length in seconds of the video or animation being loaded. Can also be calculated by dividing
_totalframes
by the FPS (frames per second).Returns:
 An object with properties
seconds
andpercent
defined. Propertypercent
is a org.casalib.math.Percent object.
Usage:

var bufferInfo:Object = LoadUtil.calculateBuffer(102400, 1536000, 0, 5000, 30); trace("File will be buffered in " + bufferInfo.seconds + " seconds."); trace("File is " + bufferInfo.percent.getPercentage() + "% buffered.");
calculateKBps
static function calculateKBps (
bytesLoaded:Number,
startTime:Number,
elapsedTime:Number) : Number
Calculates the load speed in KBps.
Parameters:
bytesLoaded:
Number of bytes that have loaded between
startTime
and elapsedTime
.startTime :
Time in milliseconds when the load started. Can be
0
.elapsedTime:
Time in milliseconds since the load started or time when load completed.
Returns:
 Kilobytes per second.
Usage note:
 This gets kiloBYTES per second, not kilobits per second.
calculateKbps
static function calculateKbps (
bytesLoaded:Number,
startTime:Number,
elapsedTime:Number) : Number
Calculates the load speed in kbps.
Parameters:
bytesLoaded:
Number of bytes that have loaded between
startTime
and elapsedTime
.startTime :
Time in milliseconds when the load started. Can be
0
.elapsedTime:
Time in milliseconds since the load started or time when load completed.
Returns:
 Kilobits per second.
Usage note:
 This gets kiloBITS per second, not kilobytes per second.
getPercentLoaded
Calculates the percent loaded.
Parameters:
loadTarget:
Any object that has either
getBytesLoaded
/getBytesTotal
or bytesLoaded
/bytesTotal
methods.Returns:
 Percent loaded.