Loader.bytesLoaded

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

loaderInstance.bytesLoaded

Description

Property (read-only); the number of bytes of content that have been loaded. The default value is 0 until content begins loading.

Example

With a Loader component and a ProgressBar component in the library of the current document, the following code creates progress bar and loader instances. It then creates a listener object with a progress event handler that shows the progress of the load. The listener is registered with the my_ldr instance.

When you create an instance with createClassObject(), you have to position it on the Stage with move(). See UIObject.move().

import mx.controls.Loader;
import mx.controls.ProgressBar;

System.security.allowDomain("http://www.flash-mx.com");

this.createClassObject(Loader, "my_ldr", 10);
this.createClassObject(ProgressBar, "my_pb", 20, {source:"my_ldr"});

my_ldr.move(1, 50);
my_pb.move(1, 1);

var loaderListener:Object = new Object();
loaderListener.progress = function(evt_obj:Object) {
 // evt_obj.target is the component that generated the progress event,
 // that is, the loader.
 my_pb.setProgress(my_ldr.bytesLoaded, my_ldr.bytesTotal);
 // Show progress.
};
my_ldr.addEventListener("progress", loaderListener);
my_ldr.contentPath = "http://www.flash-mx.com/images/image2.jpg";