Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > MovieClipLoader > onLoadError (MovieClipLoader.onLoadError event listener) | |||
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.
Availability: ActionScript 1.0; Flash Player 7
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.
The following example displays information in the Output panel when an image fails to load. 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.
addListener (MovieClipLoader.addListener method), loadClip (MovieClipLoader.loadClip method), onLoadStart (MovieClipLoader.onLoadStart event listener), onLoadComplete (MovieClipLoader.onLoadComplete event listener)
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00002000.html