的SWFLoader:我能赶上从加载的SWF所有的异常? [英] swfloader: can I catch all the exceptions from the loaded swf?

查看:391
本文介绍了的SWFLoader:我能赶上从加载的SWF所有的异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的SWFLoader加载SWF到另一个swf,我想捕获所有抛出的瑞士法郎内的异常,是不是可行?

I am loading a swf into another swf using swfloader, I want to catch all the exceptions thrown by the inner swf, is it doable?

推荐答案

下面是一些基础知识,可以帮助。总之,你不能使用的try / catch在这里。

Here are some basics that may help. In short, you cannot use try/catch here.

在加载外部内容的错误不能被捕获与try..catch..finally语句。相反,你必须创建事件处理程序处理,并捕获的错误事件。如果您没有分配给错误事件的事件侦听器,并发生了错误,Flash播放器将通知未处理的错误事件你。

Errors in loading external content cannot be caught with try..catch..finally statements. Instead you have to create event handlers to handle and "catch" the error events. If you do not have an event listener assigned to an error event and that error occurs, the Flash player will inform you of the unhandled error event.

// creating listeners for error events handles
// asynchronous errors
target.addEventListener(ErrorEvent.TYPE, handler);
function handler(event:ErrorEvent):void {
// handle error
}

如果你想调用自己的异步错误

,所有你需要做的是调度使用则dispatchEvent事件,它是类型的ErrorEvent的。当未处理的ErrorEvent在Flash创作时到达Flash播放器,输出窗口将显示错误。

If you want to invoke your own asynchronous errors, all you need to do is dispatch an event using dispatchEvent that is of the type ErrorEvent. When an unhandled ErrorEvent reaches the Flash player when authoring in Flash, the output window will display the error.

target.dispatchEvent(new ErrorEvent("type"));

这篇关于的SWFLoader:我能赶上从加载的SWF所有的异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆