gpt4 book ai didi

flash - 如何处理未处理的 IOErrorEvent

转载 作者:行者123 更新时间:2023-12-01 11:05:59 25 4
gpt4 key购买 nike

如何处理\捕获这个错误

Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type.

我尝试使用 AS3 将损坏的图像加载到 MovieClip 中我尝试使用 try & catch 但没办法我也尝试添加 EventListener

loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

但它没有捕获到这个错误

有什么帮助吗?!

最佳答案

如果你想捕获任何看不见的错误,你可以使用标准的 try-catch block 。

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 部分运行 - 错误 #2124。

关于flash - 如何处理未处理的 IOErrorEvent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5894649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com