So you want to load an image (jpg or something else like a swf) using AS3 ( actionscript 3 ) and then return the error ( or do something else like show a default image ) if the image doesn’t exist.
/*code*/
import flash.net.URLLoader;
import flash.display.Loader;
import flash.events.*;
var i = new Loader();
i.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
i.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
i.load(new URLRequest(“”));
//change the url of the above line to something that doesn’t exist to test the error
movieClipInstance.addChild(i);
function errorHandler(event:ErrorEvent):void {
trace(“errorHandler: ” + event);
}
阅读(1802) | 评论(0) | 转发(0) |