Packagenet.guttershark.util
Classpublic final class Bandwidth
InheritanceBandwidth Inheritance flash.events.EventDispatcher

The Bandwidth class downloads a bitmap file, and benchmarks the client's bandwidth.


Example
Sniffing the user's bandwidth:
 
  import net.guttershark.managers.EventManager;
  import net.guttershark.util.Bandwidth;
  
     var bs:Bandwidth = new Bandwidth();
     em.handleEvents(bs,this,"onBS");
     bs.detect();
     public function onBSComplete():void
     {
       trace(Bandwidth.Speed);
       trace(Bandwidth.Speed==Bandwidth.HIGH);
       trace(Bandwidth.Speed==Bandwidth.MED);
       trace(Bandwidth.Speed==Bandwidth.LOW);
       //Bandwidth.Speed will be equal to Bandwidth.LOW / MED / HIGH. One of the three.
     }
  

See also

DocumentController class


Public Properties
 PropertyDefined by
  contentLoader : URLLoader
The loader used to load the bandwidth image.
Bandwidth
  Speed : String = "null"
[static] Pointer to which bandwidth is detected.
Bandwidth
Public Methods
 MethodDefined by
  
Bandwidth(image:URLRequest = null, targetLowBandwidth:Number = 256, targetMedBandwidth:Number = 550)
Constructor for Bandwidth instances.
Bandwidth
  
detect():void
Inititiates the bandwidth detection process.
Bandwidth
  
dispose():void
Dispose of internal variables.
Bandwidth
Public Constants
 ConstantDefined by
  HIGH : String = "high"
[static] High bandwidth
Bandwidth
  LOW : String = "low"
[static] Low bandwidth
Bandwidth
  MED : String = "med"
[static] Medium bandwidth
Bandwidth
Property detail
contentLoaderproperty
public var contentLoader:URLLoader

The loader used to load the bandwidth image.

Speedproperty 
public static var Speed:String = "null"

Pointer to which bandwidth is detected. Default is Bandwidth.MED

Constructor detail
Bandwidth()constructor
public function Bandwidth(image:URLRequest = null, targetLowBandwidth:Number = 256, targetMedBandwidth:Number = 550)

Constructor for Bandwidth instances.

Parameters
image:URLRequest (default = null) — The target KBps for low bandwidth.
 
targetLowBandwidth:Number (default = 256) — The target KBps for med bandwidth.
 
targetMedBandwidth:Number (default = 550) — This is an optional parameter - by default the sniffer loads a reference to ./bandwidth.jpg. You can pass a different URLRequest here to change what file is used in the bandwidth detection.

The target high bandwidth is not a parameter because anything higher than the target medium bandwidth KBps will automatically be high.

Method detail
detect()method
public function detect():void

Inititiates the bandwidth detection process.

dispose()method 
public function dispose():void

Dispose of internal variables.

Constant detail
HIGHconstant
public static const HIGH:String = "high"

High bandwidth

LOWconstant 
public static const LOW:String = "low"

Low bandwidth

MEDconstant 
public static const MED:String = "med"

Medium bandwidth