Flash 如何处理未处理的IOErrorEvent
如何处理\捕获此错误Flash 如何处理未处理的IOErrorEvent,flash,actionscript-3,actionscript,air,Flash,Actionscript 3,Actionscript,Air,如何处理\捕获此错误 Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type. 我尝试用AS3将损坏的图像加载到MovieClip中 我试着用try&catch,但没有办法 我还试着添加一个列表 loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError); 但它没有捕捉到这个错误 Unhandled IOErr
Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type.
我尝试用AS3将损坏的图像加载到MovieClip中
我试着用try&catch,但没有办法
我还试着添加一个列表
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
但它没有捕捉到这个错误
Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type.
有人帮忙吗 如果要捕获任何看不见的错误,可以使用标准的try-catch块
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener("complete", ldrDone);
ldr.contentLoaderInfo.addEventListener("ioError", ldrError);
ldr.load(new URLRequest("FILE-NAME-COMES-HERE"));
function ldrDone(evt:*):void
{
//if the file can be loaded into a Loader object, this part runs
var temp:*;
try
{
temp = evt.target.content;
//add it to the stage
stage.addChild(temp);
//this traces whether the loaded content is a Bitmap (jpg, gif, png) or a MovieClip (swf)
var classOfObject:String = flash.utils.getQualifiedClassName(temp);
trace(classOfObject);
}
catch(error:*)
{
trace("some error was caught, for example swf is AS2, or whatever, like Error #2180");
}
}
function ldrError(evt:*):void
{
//if the file can't be loaded into a Loader object, this part runs
trace("this is the error part, Error #2124 won't show up");
}
这会捕获错误,比如您试图加载的swf是旧的swf(用AS2发布)-错误#2180
如果文件找不到,或者看起来不是任何可加载格式,那么ioError部分将运行-Error#2124。是否存在错误侦听器函数?你在使用URLLoader吗?是的,我创建了一个错误函数,是的,我在使用URLLoader,它在加载图像时工作正常,但是当我使用损坏的图像时,我无法处理错误尝试使用
URLStream
:对于图像,我想你应该使用flash.display.Loader。只是为了补充你的答案。。。我不知道2011年的情况,但今天,在AIRDK 19中,IOErrorEvent.IO_错误会在损坏的图像上缓存#2124错误消息。