BandwidthObserver
| Kind of class: | class |
|---|---|
| Inherits from: | CoreObject |
| Version: | 12/20/06 |
| Author: | Aaron Clinger |
| Classpath: | org.casaframework.load.BandwidthObserver |
| File last modified: | Monday, 08 January 2007, 09:57:51 |
Calculates load speeds for individual watched files and remembers the values for comparison with other loads.
Since:
Flash Player 7
Example:
this.createEmptyMovieClip("loadZone_mc", this.getNextHighestDepth()); function onImageLoadProgress(sender:MediaLoad, bytesLoaded:Number, bytesTotal:Number):Void { trace("File is loading at " + this.bandwidth.getKBps() + " kBps."); } var mediaLoad:MediaLoad = new MediaLoad(this.loadZone_mc, "test.jpg"); var bandwidth:BandwidthObserver = BandwidthObserver.observe(this.mediaLoad); this.mediaLoad.addEventObserver(this, BytesLoad.EVENT_LOAD_PROGRESS, "onImageLoadProgress"); this.mediaLoad.start();
Usage note:
This class only calculates kiloBYTES per seconds, not the bandwidth speed norm kilobits per second. Bits are not very useful in flash; flash only knows object's size in bytes so kBps is a much more useful number. If you need to find kbps or bits use org.casaframework.util.ConversionUtil to convert the values.
Summary
Instance properties
Instance properties inherited from CoreObject
Class methods
Instance methods
Instance methods inherited from CoreObject
Class methods
getAverageKBps
static function getAverageKBps (
) : Number
Returns:
Returns the average kBps of all observed loads.
getHighestKBps
static function getHighestKBps (
) : Number
Returns:
Returns the highest/fastest kBps of all observed loads.
getLowestKBps
static function getLowestKBps (
) : Number
Returns:
Returns the lowest/slowest kBps of all observed loads.
observe
static function observe (
loadItem:BytesLoad) : BandwidthObserver
Defines load to observe and calculate the speed of transfer in kBps.
Parameters:
loadItem:
File to observe the request and download speed. Can be any class that inherits from org.casaframework.load.base.BytesLoad.
loadItem also has to dispatch events "onLoadStart", "onLoadProgress", "onLoadComplete" and "onLoadError".Returns:
Returns BandwidthObserver instance.
Instance methods
getKBps
function getKBps (
) : Number
Returns:
returns the kBps of the specific load this instance is observing.