n99creations
  View Snippet
Log In!
Not a member? Register
Forgot Password? Resend
_recordDownloadSpeed (Object._recordDownloadSpeed method)
Creator: nathan99
Date Added: May 13, 2007
Rating: 100% (4 of 4 Votes)


Description:
Monitors how fast an Object is downloading, updating at one second intervals. This does not return any value, rather it makes a new property on the Object named _downloadSpeed which can be accessed to retrieve the download speed of the Object.

The _recordDownloadSpeed() method can be used to track the download speed of any Object that can access the getBytesLoaded() method.

Example
The following example creates a new Sound() object, begins to load myMP3File.mp3 and then calls the Object._recordDownloadSpeed() method to monitor how fast the mp3 is downloading. An interval is set up to output the download speed (in kilobits per second) into the output dialogue box and calling the Object._downloadSpeed parameter:
Actionscript Code:
Object.prototype._recordDownloadSpeed = function():Void {
  clearInterval(this.getRate);
  this.getRate = setInterval(function (target):Void {
    target.dist = target.dlspeed ? target.getBytesLoaded()-target.dlspeed : target.getBytesLoaded();
    target._downloadSpeed = Math.round(target.dist/1024);
    target.dlspeed = target.getBytesLoaded();
  }, 1000, this);
};
my_sound = new Sound();
my_sound.loadSound("./myMP3File.mp3");
my_sound._recordDownloadSpeed();
setInterval(function ():Void {
  trace(my_sound._downloadSpeed);
}, 1000);
This method can also be used for loadMovie(), LoadVars(), etc...




There are no comments to display.

You must be signed in to post a comment.
Click here to log in.
Click here to register.