Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > MovieClipLoader > onLoadComplete (MovieClipLoader.onLoadComplete event listener) | |||
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.
Availability: ActionScript 1.0; Flash Player 7 - Support for unanimated GIF files, PNG files, and progressive JPEG files is available as of Flash Player 8.
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.
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.
addListener (MovieClipLoader.addListener method), loadClip (MovieClipLoader.loadClip method), onLoadStart (MovieClipLoader.onLoadStart event listener), onLoadError (MovieClipLoader.onLoadError event listener), onLoadInit (MovieClipLoader.onLoadInit event listener)
Flash CS3
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00001999.html
Comments
thenetdragon said on Aug 25, 2007 at 11:50 AM :