|
ActionScript Reference Movie Clip Control
MovieClipLoader.addListener()
MovieClipLoader.addListener()
Entry Owner: Jen deHaan, Started: November 12, 2003
Availability:
Flash Player 7
Usage:
MovieClipLoader.addListener( listenerObject );
Description:
Adds a listener object to a MovieClipLoader instance. This allows you to catch listener callbacks and execute blocks of code when certain events are triggered. The events which can be caught are:
- onLoadStart
- onLoadProgress
- onLoadComplete
- onLoadInit
- onLoadError
Example:
The following code creates a new MovieClipLoader object and waits for the onLoadError listener to be triggered.
this.createEmptyMovieClip("logo_mc", this.getNextHighestDepth());
var myImage:MovieClipLoader = new MovieClipLoader();
var listenerObject:Object = new Object();
listenerObject.onLoadError = function() {
trace("an error occurred.");
};
myImage.addListener(listenerObject);
myImage.loadClip("images/image1.jpg", logo_mc);
If you want to see which order the listeners are called, you can simply create listeners for each event and place trace statements in the functions as seen in the following code.
this.createEmptyMovieClip("logo_mc", this.getNextHighestDepth());
var myImage:MovieClipLoader = new MovieClipLoader();
var listenerObject:Object = new Object();
listenerObject.onLoadComplete = function() {
trace(" -- onLoadComplete");
};
listenerObject.onLoadProgress = function() {
trace(" -- onLoadProgress");
};
listenerObject.onLoadStart = function() {
trace(" -- onLoadStart");
};
listenerObject.onLoadInit = function() {
trace(" -- onLoadInit");
};
listenerObject.onLoadError = function() {
trace(" -- onLoadError");
};
myImage.addListener(listenerObject);
myImage.loadClip("images/image1.jpg", logo_mc);
|