Flash Player 7.
listenerObject.onLoadProgress = function([target_mc:Object[,loadedBytes:Number[,totalBytes:Number] ] ] ) { // your statements here }
listenerObject A listener object that was added using MovieClipLoader.addListener().
target_mc A movie clip loaded by a MovieClipLoader.loadClip() method. This parameter is optional.
loadedBytes The number of bytes that had been loaded when the listener was invoked.
totalBytes The total number of bytes in the file being loaded.
Nothing.
Listener; invoked every time the loading content is written to disk during the loading process (that is, between MovieClipLoader.onLoadStart and MovieClipLoader.onLoadComplete). You can use this method to display information about the progress of the download, using the loadedBytes and totalBytes parameters.
The value for target_mc identifies the movie clip this call is being made for. This is useful if you are loading multiple files with the same set of listeners. This optional parameter is passed to your ActionScript.
The following example creates a progress bar using the Drawing API. The progress bar displays the loading progress of an image using the onLoadProgress listener. When the image finishes loading, the progress bar is removed from the Stage. You must replace the URL parameter of the image_mcl.loadClip() command so that the parameter refers to a valid JPEG file using HTTP. If you attempt to use this example to load a local file that resides on your hard disk, this example will not work properly because, in test movie mode, Flash Player loads local files in their entirety. Add the following ActionScript to your FLA or AS file:
this.createEmptyMovieClip("progressBar_mc", 0);
progressBar_mc.createEmptyMovieClip("bar_mc", 1);
progressBar_mc.createEmptyMovieClip("stroke_mc", 2);
with (progressBar_mc.stroke_mc) {
lineStyle(0, 0x000000);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
}
with (progressBar_mc.bar_mc) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
endFill();
_xscale = 0;
}
progressBar_mc._x = 2;
progressBar_mc._y = 2;
//
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
progressBar_mc.bar_mc._xscale = 0;
};
mclListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
progressBar_mc.bar_mc._xscale = Math.round(bytesLoaded/bytesTotal*100);
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
progressBar_mc.removeMovieClip();
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._height = 320;
target_mc._width = 240;
};
this.createEmptyMovieClip("image_mc", 100);
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("[place a valid URL pointing to a JPEG file here]", image_mc);
MovieClipLoader.getProgress()
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001581.html
Comments
Spen said on Nov 27, 2004 at 6:39 PM : boldhead said on Nov 27, 2004 at 7:51 PM : S. Jackson said on Jan 17, 2005 at 2:36 PM :