Loader.percentLoaded

Availability

Flash Player 6.0.79.

Edition

Flash MX 2004.

Usage

loaderInstance.percentLoaded

Description

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 a easily readable form. Use the following code to round the figure to the nearest integer:

Math.round(bytesLoaded/bytesTotal*100))

Example

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:

createClassObject(Loader, "loader", 0);
loadListener = new Object();
loadListener.progress = function(eventObj){
  // eventObj.target is the component which generated the change event,
  // i.e., the Loader.
  trace("logo.swf is " + loader.percentLoaded + "% loaded."); // track loading progress
}
loader.addEventListener("complete", loadListener);
loader.content = "logo.swf";