PackageTop Level
Classpublic class MovieClipLoader
InheritanceMovieClipLoader Inheritance Object

Player version: Flash Player 7

This class lets you implement listener callbacks that provide status information while SWF, JPEG, GIF, and PNG files are being loaded into movie clips. To use MovieClipLoader features, use MovieClipLoader.loadClip() instead of loadMovie() or MovieClip.loadMovie() to load SWF files.

Note: MovieClipLoader support for GIF and PNG file formats was new to Flash 8. If you import a project from an earlier version of the tool, you need to update the Publish settings to target Flash 8, or later, otherwise only SWF and JPEG file formats will work.

After you issue the MovieClipLoader.loadClip() command, the following events take place in the order listed:

When MovieClipLoader.onLoadInit has been invoked, you can set properties, use methods, and otherwise interact with the loaded movie.

If the file fails to load completely, the MovieClipLoader.onLoadError listener is invoked.

Note: Some browsers' caching of files locally may interfere with MovieClipLoader events. While developing SWF files, clear your browser's cache before testing MovieClipLoader events.



Public Properties
 Property
  checkPolicyFile : Boolean
Specifies whether Flash Player should attempt to download a policy file from the loaded object's server before beginning to load the object itself.
 Properties inherited from class Object
 __proto__, __resolve, constructor, prototype
Public Methods
 Method
  
Creates a MovieClipLoader object that you can use to implement a number of listeners to respond to events while a SWF, JPEG, GIF, or PNG file is downloading.
  
Registers an object to receive notification when a MovieClipLoader event handler is invoked.
  
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.
  
loadClip(url:String, target:Object):Boolean
Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into a movie clip in Flash Player while the original movie is playing.
  
Removes the listener that was used to receive notification when a MovieClipLoader event handler was invoked.
  
Removes a movie clip that was loaded by using MovieClipLoader.loadClip().
 Methods inherited from class Object
 addProperty, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch
Events
 EventSummaryDefined by
  
onLoadComplete = function([target_mc:MovieClip], [httpStatus:Number]) {}
Invoked when a file that was loaded with MovieClipLoader.loadClip() is completely downloaded.MovieClipLoader
  
onLoadError = function(target_mc:MovieClip, errorCode:String, [httpStatus:Number]) {}
Invoked when a file loaded with MovieClipLoader.loadClip() has failed to load.MovieClipLoader
  
onLoadInit = function([target_mc:MovieClip]) {}
Invoked when the actions on the first frame of the loaded clip have been executed.MovieClipLoader
  
onLoadProgress = function([target_mc:MovieClip], loadedBytes:Number, totalBytes:Number) {}
Invoked every time the loading content is written to the hard disk during the loading process (that is, between MovieClipLoader.onLoadStart and MovieClipLoader.onLoadComplete).MovieClipLoader
  
onLoadStart = function([target_mc:MovieClip]) {}
Invoked when a call to MovieClipLoader.loadClip() has begun to download a file.MovieClipLoader
Property detail
checkPolicyFileproperty
public var checkPolicyFile:Boolean

Language version: ActionScript 2.0
Player version: Flash Player 9

Specifies whether Flash Player should attempt to download a policy file from the loaded object's server before beginning to load the object itself.

Set this flag to true when you are loading an image (JPG, GIF, or PNG) from outside the calling SWF file's own domain and you expect to access the content of that image using BitmapData.draw(). If you attempt this operation without having specified checkPolicyFile at loading time, you may encounter a security error because the needed policy file has not been downloaded yet.

When you call MovieClipLoader.loadClip() with checkPolicyFile set to true, Flash Player does not begin downloading the object specified in your url until it has either successfully downloaded a relevant policy file or discovered that no such policy file exists. Flash Player first considers policy files that have already been downloaded, then attempts to download any pending policy files specified in calls to System.ecurity.loadPolicyFile(), then attempts to download a policy file from the default location that corresponds to url, which is /crossdomain.xml on the same server as url. In all cases, Flash Player requires that the given policy file exists on its server, that the file provides access to the object at url by virtue of the policy file's location, and that the file permits access by the domain of the calling SWF file by virtue of one or more <allow-access-from> tags.

If you set checkPolicyFile to true, Flash Player waits until policy file completion to begin the main download that you specify in MovieClipLoader.loadClip(). Thus, as long as the policy file that you need exists, as soon as you have received any event notifications from your MovieClipLoader, the policy file download is complete and you can safely begin performing operations that require the policy file.

If you set checkPolicyFile to true, and no relevant policy file is found, you do not receive any error indication until you attempt an operation that causes a security error.

Try to avoid setting checkPolicyFile to true if you will not be needing pixel-level access to the image that you are loading. Checking for a policy file in this case is wasteful, because it may delay the start of your download, and may consume network bandwidth unnecessarily.

Also try to avoid setting checkPolicyFile to true if you are using MovieClipLoader.loadClip() to download a SWF file. This is because SWF-to-SWF permissions are not controlled by policy files, but rather by Security.allowDomain(), and checkPolicyFile has no effect when you load a SWF file. Checking for a policy file in this case is wasteful because it may delay the start of your SWF download and may consume network bandwidth unnecessarily. (Flash Player cannot tell whether your main download will be a SWF file or an image, because the policy file download occurs before the main download.)

Be careful with checkPolicyFile if you are downloading an object from a URL that may use server-side HTTP redirects. Flash Player always attempts to retrieve policy files that correspond to the initial URL that you specify in loadClip. If the final object comes from a different URL because of HTTP redirects, then the initially downloaded policy file(s) might not be applicable to the object's final URL, which is the URL that matters in security decisions.

Constructor detail
MovieClipLoader()constructor
public function MovieClipLoader()

Player version: Flash Player 7

Creates a MovieClipLoader object that you can use to implement a number of listeners to respond to events while a SWF, JPEG, GIF, or PNG file is downloading.

See also


Example
See MovieClipLoader.loadClip().

Method detail
addListener()method
public function addListener(listener:Object):Boolean

Player version: Flash Player 7

Registers an object to receive notification when a MovieClipLoader event handler is invoked.

Parameters
listener:Object — An object that listens for a callback notification from the MovieClipLoader event handlers.

Returns
Boolean — A Boolean value. Returns true if the listener was established successfully; otherwise false.

See also


Example
The following example loads an image into a movie clip called image_mc. The movie clip instance is rotated and centered on the Stage, and both the Stage and movie clip have a stroke drawn around their perimeters.
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
    target_mc._x = Stage.width/2-target_mc._width/2;
    target_mc._y = Stage.height/2-target_mc._height/2;
    var w:Number = target_mc._width;
    var h:Number = target_mc._height;
    target_mc.lineStyle(4, 0x000000);
    target_mc.moveTo(0, 0);
    target_mc.lineTo(w, 0);
    target_mc.lineTo(w, h);
    target_mc.lineTo(0, h);
    target_mc.lineTo(0, 0);
    target_mc._rotation = 3;
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc);

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.

getProgress()method 
public function getProgress(target:Object):Object

Player version: Flash Player 7

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.

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.

See also


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.

loadClip()method 
public function loadClip(url:String, target:Object):Boolean

Player version: Flash Player 7 — Support for unanimated GIF files, PNG files, and progressive JPEG files is available as of Flash Player 8.

Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into a movie clip in Flash Player while the original movie is playing. If you load an animated GIF, only the first frame is displayed. Using this method you can display several SWF files at once and switch between SWF files without loading another HTML document.

Using the loadClip() method instead of loadMovie() or MovieClip.loadMovie() has a number of advantages. The following handlers are implemented by the use of a listener object. You activate the listener by registering it with the MovieClipLoader class by using MovieClipLoader.addListener(listenerObject).

A SWF file or image loaded into a movie clip inherits the position, rotation, and scale properties of the movie clip. You can use the target path of the movie clip to target the loaded movie.

You can use the loadClip() method to load one or more files into a single movie clip or level; MovieClipLoader listener objects are passed to the loading target movie clip instance as parameters. Alternatively, you can create a different MovieClipLoader object for each file that you load.

Use MovieClipLoader.unloadClip() to remove movies or images loaded with this method or to cancel a load operation that is in progress.

MovieClipLoader.getProgress() and MovieClipLoaderListener.onLoadProgress do not report the actual bytesLoaded and bytesTotal values in the authoring player when the files are local. When you use the Bandwidth Profiler feature in the authoring environment, MovieClipLoader.getProgress() and MovieClipLoaderListener.onLoadProgress report the download at the actual download rate, not at the reduced bandwidth rate that the Bandwidth Profiler provides.

When using this method, consider the Flash Player security model.

For more information related to security, see the following:

Note: IPv6 (Internet Protocol version 6) is supported in Flash Player 9.0.115.0 and later. IPv6 is a version of Internet Protocol that supports 128-bit addresses (an improvement on the earlier IPv4 protocol that supports 32-bit addresses). You might need to activate IPv6 on your networking interfaces. For more information, see the Help for the operating system hosting the data. If IPv6 is supported on the hosting system, you can specify numeric IPv6 literal addresses in URLs enclosed in brackets ([]), as in the following.

      rtmp://[2001:db8:ccc3:ffff:0:444d:555e:666f]:1935/test
      

Parameters
url:String — The absolute or relative URL of the SWF, JPEG, GIF, or PNG file to be loaded. A relative path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// or file:///. Filenames cannot include disk drive specifications.
 
target:Object — The target path of a movie clip, or an integer specifying the level in Flash Player into which the movie will be loaded. The target movie clip is replaced by the loaded SWF file or image.

Returns
Boolean — A Boolean value. Returns true if the URL request was sent successfully; otherwise false.

See also


Example
The following example shows how to use the MovieClipLoader.loadClip() method by creating a handler for the onLoadInit event and then making the request.

You should either place the following code directly into a frame action on a Timeline, or paste it into a class that extends MovieClip. This code also expects an image named YourImage.jpg to exist in the same directory as the compiled SWF file.

var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("YourImage.jpg", container);

function onLoadInit(mc:MovieClip) {
    trace("onLoadInit: " + mc);
}

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.

removeListener()method 
public function removeListener(listener:Object):Boolean

Player version: Flash Player 7

Removes the listener that was used to receive notification when a MovieClipLoader event handler was invoked. No further loading messages will be received.

Parameters
listener:Object — A listener object that was added by using MovieClipLoader.addListener().

Returns
Boolean — A Boolean value. Returns true if the listener was removed successfully; otherwise false.

See also


Example
The following example loads an image into a movie clip, and enables the user to start and stop the loading process using two buttons called start_button and stop_button. When the user starts or stops the progress, information is displayed in the Output panel.When the user starts or stops the progress, information writes to the log file.
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
    trace("\t onLoadStart");
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
    trace("\t onLoadComplete");
};
mclListener.onLoadError = function(target_mc:MovieClip, errorCode:String) {
    trace("\t onLoadError: "+errorCode);
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
    trace("\t onLoadInit");
    start_button.enabled = true;
    stop_button.enabled = false;
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
//
start_button.clickHandler = function() {
    trace("Starting...");
    start_button.enabled = false;
    stop_button.enabled = true;
    //
    image_mcl.addListener(mclListener);
    image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc);
};
stop_button.clickHandler = function() {
    trace("Stopping...");
    start_button.enabled = true;
    stop_button.enabled = false;
    //
    image_mcl.removeListener(mclListener);
};
stop_button.enabled = false;

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.

unloadClip()method 
public function unloadClip(target:Object):Boolean

Player version: Flash Player 7

Removes a movie clip that was loaded by using MovieClipLoader.loadClip(). If you issue this command while a movie is loading, MovieClipLoader.onLoadError is invoked.

Parameters
target:Object — The string or integer that is passed to the corresponding call to my_mcl.loadClip().

Returns
Boolean — A Boolean value. Returns true if the movie clip was removed successfully; otherwise false.

See also


Example
The following example loads an image into a movie clip called image_mc. When you click the movie clip, the movie clip is removed and information is displayed in the Output panel.When you click the movie clip, the movie clip is removed and information writes to the log file.
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
    target_mc._x = 100;
    target_mc._y = 100;
    target_mc.onRelease = function() {
    trace("Unloading clip...");
    trace("\t name: "+target_mc._name);
    trace("\t url:  "+target_mc._url);
    image_mcl.unloadClip(target_mc);
    };
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc);

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.

Event detail
onLoadCompleteevent listener

public onLoadComplete = function([target_mc:MovieClip], [httpStatus:Number]) {}

Player version: Flash Player 7 — Support for unanimated GIF files, PNG files, and progressive JPEG files is available as of Flash Player 8.

Invoked when a file that was loaded with MovieClipLoader.loadClip() is completely downloaded. Call this listener on a listener object that you add using MovieClipLoader.addListener(). The onLoadComplete event listener is passed by Flash Player to your code, but you do not have to implement all of the parameters in the listener function. The value for target_mc identifies the movie clip for which this call is being made. This identification is useful when multiple files are being loaded with the same set of listeners.

In Flash Player 8, or later, this listener can return an HTTP status code. If Flash Player cannot get the status code from the server, or if Flash Player cannot communicate with the server, the default value of 0 is passed to your ActionScript code. A value of 0 can be generated in any player (for example, if a malformed URL is requested), and a value of 0 is always generated by the Flash Player plug-in when run in the following browsers, which cannot pass HTTP status codes from the server to Flash Player: Netscape, Mozilla, Safari, Opera, and Internet Explorer for the Macintosh.

It's important to understand the difference between MovieClipLoader.onLoadComplete and MovieClipLoader.onLoadInit. The onLoadComplete event is called after the SWF, JPEG, GIF, or PNG file loads, but before the application is initialized. At this point, it is impossible to access the loaded movie clip's methods and properties, and therefore you cannot call a function, move to a specific frame, and so on. In most situations, it's better to use the onLoadInit event instead, which is called after the content is loaded and fully initialized.

Parameters
target_mc:MovieClip [optional] — A movie clip loaded by the MovieClipLoader.loadClip() method.
 
httpStatus:Number [optional] — (Flash Player 8 or later, only) The HTTP status code returned by the server. For example, a status code of 404 indicates that the server has not found anything matching the requested URI. For more information about HTTP status codes, see sections 10.4 and 10.5 of the HTTP specification at ftp://ftp.isi.edu/in-notes/rfc2616.txt.

Example
The following example creates a movie clip, a new MovieClipLoader instance, and an anonymous event listener which listens for the onLoadComplete event but waits for an onLoadInit event to interact with the loaded element properties.
var loadListener:Object = new Object();

loadListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void {
    trace(">> loadListener.onLoadComplete()");
    trace(">> =============================");
    trace(">> target_mc._width: " + target_mc._width);    // 0
    trace(">> httpStatus: " + httpStatus);
}

loadListener.onLoadInit = function(target_mc:MovieClip):Void {
    trace(">> loadListener.onLoadInit()");
    trace(">> =============================");
    trace(">> target_mc._width: " + target_mc._width);    // 315
}

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcLoader.loadClip("http://www.w3.org/Icons/w3c_main.png", mc);

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

onLoadErrorevent listener 

public onLoadError = function(target_mc:MovieClip, errorCode:String, [httpStatus:Number]) {}

Player version: Flash Player 7

Invoked when a file loaded with MovieClipLoader.loadClip() has failed to load. This listener can be invoked for various reasons; for example, if the server is down, the file is not found, or a security violation occurs.

Call this listener on a listener object that you add by using MovieClipLoader.addListener().

The value of target_mc identifies the movie clip for which this call is being made. This parameter is useful if you are loading multiple files with the same set of listeners.

For the errorCode parameter, the string "URLNotFound" is returned if neither the MovieClipLoader.onLoadStart or MovieClipLoader.onLoadComplete listener has been called; for example, if a server is down or the file is not found. The string "LoadNeverCompleted" is returned if MovieClipLoader.onLoadStart was called but MovieClipLoader.onLoadComplete was not called; for example, if the download was interrupted because of server overload, server crash, and so on.

In Flash Player 8 or later, this listener can return an HTTP status code in the httpStatus parameter. If Flash Player cannot get a status code from the server, or if Flash Player cannot communicate with the server, the default value of 0 is passed to your ActionScript code. A value of 0 can be generated in any player (for example, if a malformed URL is requested), and a value of 0 is always generated by the Flash Player plug-in when run in the following browsers, which cannot pass HTTP status codes from the server to Flash Player: Netscape, Mozilla, Safari, Opera, and Internet Explorer for the Macintosh. A value of 0 can also be generated if the player did not try to make the URL request to perform the load operation. This can happen because the request violates security sandbox rules for the SWF file.

Parameters
target_mc:MovieClip — A movie clip loaded by the MovieClipLoader.loadClip() method.
 
errorCode:String — A string that explains the reason for the failure, either "URLNotFound" or "LoadNeverCompleted".
 
httpStatus:Number [optional] — (Flash Player 8 or later, only) The HTTP status code returned by the server. For example, a status code of 404 indicates that the server has not found anything that matches the requested URI. For more information about HTTP status codes, see sections 10.4 and 10.5 of the HTTP specification at ftp://ftp.isi.edu/in-notes/rfc2616.txt.

Example
The following example displays information in the Output panel when an image fails to load.The following example writes information to the log file when an image fails to load. This occurs when you test the following ActionScript, because the image does not exist in the specified location. The URL used in this example is for demonstration purposes only; replace it with your own valid URL.
var loadListener:Object = new Object();

loadListener.onLoadError = function(target_mc:MovieClip, errorCode:String, httpStatus:Number) {
    trace(">> loadListener.onLoadError()");
    trace(">> ==========================");
    trace(">> errorCode: " + errorCode);
    trace(">> httpStatus: " + httpStatus);
}

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);

var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mcLoader.loadClip("http://www.fakedomain.com/images/bad_hair_day.jpg", mc);     

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

onLoadInitevent listener 

public onLoadInit = function([target_mc:MovieClip]) {}

Player version: Flash Player 7

Invoked when the actions on the first frame of the loaded clip have been executed. When this listener has been invoked, you can set properties, use methods, and otherwise interact with the loaded movie. Call this listener on a listener object that you add by using MovieClipLoader.addListener().

The value for target_mc identifies the movie clip for which this call is being made. This parameter is useful if you are loading multiple files with the same set of listeners.

Parameters
target_mc:MovieClip [optional] — A movie clip loaded by the MovieClipLoader.loadClip() method.

Example
The following example loads an image into a movie clip instance called image_mc. The onLoadInit and onLoadComplete events are used to determine how long it takes to load the image. This information is displayed in a text field called timer_txt.
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
    target_mc.startTimer = getTimer();
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
    target_mc.completeTimer = getTimer();
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
    var timerMS:Number = target_mc.completeTimer-target_mc.startTimer;
    target_mc.createTextField("timer_txt", target_mc.getNextHighestDepth(), 0, target_mc._height, 
target_mc._width, 22);
    target_mc.timer_txt.text = "loaded in "+timerMS+" ms.";
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc);

The following example checks whether a movie has loaded into a movie clip created at runtime. The URL used in this example is for demonstration purposes only; replace it with your own valid URL.

this.createEmptyMovieClip("tester_mc", 1);
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
    trace("movie loaded");
}
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.yourserver.com/your_movie.swf", tester_mc);

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

onLoadProgressevent listener 

public onLoadProgress = function([target_mc:MovieClip], loadedBytes:Number, totalBytes:Number) {}

Player version: Flash Player 7

Invoked every time the loading content is written to the hard disk during the loading process (that is, between MovieClipLoader.onLoadStart and MovieClipLoader.onLoadComplete). Call this listener on a listener object that you add by using MovieClipLoader.addListener(). You can use this method to display information about the progress of the download, by using the loadedBytes and totalBytes parameters.

The value for target_mc identifies the movie clip for which this call is being made. This is useful when you are loading multiple files with the same set of listeners.

Note: If you attempt to use onLoadProgress in test mode with a local file that resides on your hard disk, it does not work properly because, in test mode, Flash Player loads local files in their entirety.

Parameters
target_mc:MovieClip [optional] — A movie clip loaded by the MovieClipLoader.loadClip() method.
 
loadedBytes:Number — The number of bytes that had been loaded when the listener was invoked.
 
totalBytes:Number — The total number of bytes in the file being loaded.

Example
The following example creates a movie clip, a new MovieClipLoader instance, and an anonymous event listener. It periodically outputs the progress of a load and finally provides notification when the load is complete and the asset is available to ActionScript.
var container:MovieClip = this.createEmptyMovieClip("container", this.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);
}
listener.onLoadInit = function(target:MovieClip):Void {
    trace(target + ".onLoadInit");
}
mcLoader.addListener(listener);
mcLoader.loadClip("http://www.w3.org/Icons/w3c_main.png", container);

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

onLoadStartevent listener 

public onLoadStart = function([target_mc:MovieClip]) {}

Player version: Flash Player 7

Invoked when a call to MovieClipLoader.loadClip() has begun to download a file. Call this listener on a listener object that you add by using MovieClipLoader.addListener().

The value for target_mc identifies the movie clip for which this call is being made. This parameter is useful if you are loading multiple files with the same set of listeners.

Parameters
target_mc:MovieClip [optional] — A movie clip loaded by the MovieClipLoader.loadClip() method.

Example
The following example loads an image into a movie clip instance called image_mc. The onLoadInit and onLoadComplete events are used to determine how long it takes to load the image. This information is displayed in a text field called timer_txt.
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
    target_mc.startTimer = getTimer();
};
mclListener.onLoadComplete = function(target_mc:MovieClip) {
    target_mc.completeTimer = getTimer();
};
mclListener.onLoadInit = function(target_mc:MovieClip) {
    var timerMS:Number = target_mc.completeTimer-target_mc.startTimer;
    target_mc.createTextField("timer_txt", target_mc.getNextHighestDepth(), 0, target_mc._height, 
target_mc._width, 22);
    target_mc.timer_txt.text = "loaded in "+timerMS+" ms.";
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc);

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