ActionScript 2.0 Components Language Reference |
|
|
|
| Loader component > Loader.percentLoaded | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
loaderInstance.percentLoaded
Property (read-only); a number indicating what percent of the content has loaded. Typically, this property is used to present the progress to the user in an easily readable form. Use the following code to round the figure to the nearest integer:
Math.round(bytesLoaded/bytesTotal*100))
The following example creates a Loader instance and then creates a listener object with a progress handler that traces the percent loaded and sends it to the Output panel:
import mx.controls.Loader;
this.createClassObject(Loader, "my_ldr", 999);
var loadListener:Object = new Object();
loadListener.progress = function(eventObj) {
// eventObj.target is the component that generated the progress event,
// that is, the loader.
trace("The image is "+my_ldr.percentLoaded+"% loaded.");
// Track loading progress.
};
my_ldr.addEventListener("progress", loadListener);
my_ldr.contentPath = "http://www.flash-mx.com/images/image2.jpg";
|
|
|
|