getProgress (MovieClipLoader.getProgress method)

public getProgress(target:Object) : Object

Returns the number of bytes loaded and the total number of bytes of a file that is being loaded by using MovieClipLoader.loadClip(); for compressed movies, returns the number of compressed bytes. The getProgress method lets you explicitly request this information, instead of (or in addition to) writing a MovieClipLoader.onLoadProgress listener function.

Availability: ActionScript 1.0; Flash Player 7

Parameters

target:Object - A SWF, JPEG, GIF, or PNG file that is loaded by using MovieClipLoader.loadClip().

Returns

Object - An object that has two integer properties: bytesLoaded and bytesTotal.

Example

The following example demonstrates the use of the getProgress() method. Rather than using this method, you will usually create a listener object to listen for the onLoadProgress event. Also note that the first, synchronous call to getProgress() can return the number of bytes loaded and the total number of bytes of the container and not the values for the externally requested object.

var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
var image:MovieClip = container.createEmptyMovieClip("image", container.getNextHighestDepth());

var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
    trace(target + ".onLoadProgress with " + bytesLoaded + " bytes of " + bytesTotal); 
}
mcLoader.addListener(listener);
mcLoader.loadClip("http://www.w3.org/Icons/w3c_main.png", image);

var interval:Object = new Object();
interval.id = setInterval(checkProgress, 100, mcLoader, image, interval);

function checkProgress(mcLoader:MovieClipLoader, image:MovieClip, interval:Object):Void {
    trace(">> checking progress now with : " + interval.id);
    var progress:Object = mcLoader.getProgress(image);
    trace("bytesLoaded: " + progress.bytesLoaded + " bytesTotal: " + progress.bytesTotal);
    if(progress.bytesLoaded == progress.bytesTotal) {
        clearInterval(interval.id);
    }
}

If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the MovieClip.getNextHighestDepth() method, which is used in this example.

See also

loadClip (MovieClipLoader.loadClip method), onLoadProgress (MovieClipLoader.onLoadProgress event listener)


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001996.html