View comments | RSS feed

MovieClipLoader.getProgress()

Availability

Flash Player 7.

Usage

my_mcl.getProgress(target_mc:Object) : Object

Parameters

target_mc A SWF or JPEG file that is loaded using MovieClipLoader.loadClip().

Returns

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

Description

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

Example

The following example loads an image into a draggable, dynamically created movie clip called image_mc. The number of bytes loaded and the total number of bytes for the loaded image display in a dynamically created text field called filesize_txt.

this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
   target_mc.onPress = function() {
      this.startDrag();
   };
   target_mc.onRelease = function() {
      this.stopDrag();
   };
   var mclProgress:Object = image_mcl.getProgress(target_mc);
   target_mc.createTextField("filesize_txt", target_mc.getNextHighestDepth(), 0, target_mc._height, target_mc._width, 22);
   target_mc.filesize_txt.text = mclProgress.bytesLoaded+" of "+mclProgress.bytesTotal+" bytes loaded";
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/112x112/box_studio_112x112.jpg", image_mc);

See also

MovieClipLoader.onLoadProgress

Comments


InternetInfinity said on Oct 18, 2004 at 3:10 PM :
Can I please get an Example of this function used without the listener!
jepo said on Oct 21, 2004 at 11:37 AM :
Hi,

Example follows:

var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.loadClip("http://www.flash-mx.com/images/image2.jpg", this.createEmptyMovieClip("my_mc", this.getNextHighestDepth()));
this.onEnterFrame = function() {
my_obj = my_mcl.getProgress(my_mc);
trace(my_obj.bytesLoaded+" of "+my_obj.bytesTotal);
};

However, the real power of MovieClipLoader is found in using listeners, which is why using them is encouraged. :)

Hope this helps,
Jen.
agoni__ _ said on Feb 15, 2005 at 9:32 AM :
i'm using the movie clip loader class to pre-load images, however i want to test to see if the image is in the users cache before i count up a pre-loader. so i figured putting a my_mcl.getProgress(targetMC) in the onStart listener and compairing the bytesLoaded & bytesTotal properites would let me test if the file is already in cache. however when i test it, all that traces out is 0. i'm sure i'm probably doing something wrong, but would this be considered correct usage or is there another way?

 

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/00001576.html