You can also use native bandwidth detection from ActionScript 2.0. Just as in ActionScript 3.0, you define functions named onBWCheck() and onBWDone(), and you make a call to NetConnection.call(), passing it the function name checkBandwidth.
Make sure bandwidth detection is enabled in the Application.xml file for your application:
<BandwidthDetection enabled="true">
Bandwidth detection is enabled by default. You can use an Application.xml file specific to your application or one that applies to a virtual host (see Adobe Flash Media Server Configuration Guide for details).
NetConnection.prototype.onBWCheck = function(data) {
return 0;
}
This handler must return a value, but it can be any value, even 0. The return value lets the server know the data was received.
NetConnection.prototype.onBWDone = function(bw) {
trace("bw = " + bw + " Kbps");
}
When the server completes its bandwidth detection, it calls onBWDone() and returns the bandwidth figure.
NetConnection.prototype.onStatus = function(info) {
if (info.code == "NetConnection.Connect.Success") {
this.call("checkBandwidth"); // tell server to start bandwidth detection
}
}
nc = new NetConnection();
nc.connect("rtmp://host/app");