Top Level

Class MovieClipLoader

Object


public class MovieClipLoader
extends 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.

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.




Property Summary

Properties inherited from class Object
__proto__, __resolve, constructor, prototype


Event Summary
onLoadComplete = function([target_mc:MovieClip], [httpStatus:Number]) {}
Invoked when a file that was loaded with MovieClipLoader.loadClip() is completely downloaded.
onLoadError = function(target_mc:MovieClip, errorCode:String, [httpStatus:Number]) {}
Invoked when a file loaded with MovieClipLoader.loadClip() has failed to load.
onLoadInit = function([target_mc:MovieClip]) {}
Invoked when the actions on the first frame of the loaded clip have been executed.
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).
onLoadStart = function([target_mc:MovieClip]) {}
Invoked when a call to MovieClipLoader.loadClip() has begun to download a file.


Constructor Summary
MovieClipLoader()
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.


Method Summary
addListener(listener:Object) : Boolean
Registers an object to receive notification when a MovieClipLoader event handler is invoked.
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.
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.
removeListener(listener:Object) : Boolean
Removes the listener that was used to receive notification when a MovieClipLoader event handler was invoked.
unloadClip(target:Object) : Boolean
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


Event Detail

onLoadComplete Event 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, 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 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
MovieClipLoader.addListener(), MovieClipLoader.loadClip(), MovieClipLoader.onLoadStart, MovieClipLoader.onLoadError, MovieClipLoader.onLoadInit

onLoadError Event 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, 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 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
MovieClipLoader.addListener(), MovieClipLoader.loadClip(), MovieClipLoader.onLoadStart, MovieClipLoader.onLoadComplete

onLoadInit Event 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
MovieClipLoader.addListener(), MovieClipLoader.loadClip(), MovieClipLoader.onLoadStart

onLoadProgress Event 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
MovieClipLoader.addListener(), MovieClipLoader.loadClip(), MovieClipLoader.getProgress()

onLoadStart Event 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
MovieClipLoader.addListener(), MovieClipLoader.loadClip(), MovieClipLoader.onLoadError, MovieClipLoader.onLoadInit, MovieClipLoader.onLoadComplete


Constructor Detail

MovieClipLoader Constructor

public 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.

Example
See MovieClipLoader.loadClip().

See also
MovieClipLoader.addListener(), MovieClipLoader.loadClip()


Method Detail

addListener Method

public 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.

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._width/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.

See also
MovieClipLoader.onLoadComplete, MovieClipLoader.onLoadError, MovieClipLoader.onLoadInit, MovieClipLoader.onLoadProgress, MovieClipLoader.onLoadStart, MovieClipLoader.removeListener()

getProgress Method

public 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.

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
MovieClipLoader.loadClip(), MovieClipLoader.onLoadProgress

loadClip Method

public 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 Flash Player 8:

For Flash Player 7 and later:

For more information, see the following:

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.

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.

See also
MovieClipLoader.onLoadInit

removeListener Method

public 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.

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.

See also
MovieClipLoader.addListener()

unloadClip Method

public 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.

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.

See also
MovieClipLoader.loadClip(), MovieClipLoader.onLoadError