处理 AS3 中的安全错误

发布于 2024-11-29 03:10:53 字数 965 浏览 0 评论 0原文

我在 AS3 中使用 vimeo 播放器的导入类,它是官方 vimeo 播放器 api (vimeo.com)。我想处理该类的实例抛出的任何安全错误(当对象无法加载视频的外部 URL 时抛出这些错误)。这就是我得到的:

    var clipPlayer = new VimeoPlayer("5d22d3942a54d7c75b931bab4a911857", videoID[clickedClip], fullVideoWidth, fullVideoHeight, "10", 2);
    clipPlayer.addEventListener(SecurityErrorEvent.SECURITY_ERROR , vimeoError);

当然,在代码的后面,我得到了处理事件的函数:

    function vimeoError (e : SecurityErrorEvent) : void {
        trace("vimeo player failed to load");
    }

这​​一切看起来都很简单,但是错误处理程序没有触发。我一定在这里遗漏了一些东西...也许您无法在 VimeoPlayer 对象上注册这种事件侦听器。但是,我非常确定是 VimeoPlayer 对象抛出了它们。这是我得到的示例:

Error opening URL 
'http://api.vimeo.com/moogaloop_api.swf?oauth_key=5d22d3942a54d7c75b931bab4a911857&clip_id=21185860&width=500&height=281&fullscreen=0&fp_version=10&api=1&cache_buster=565.7249609939754'
SecurityError: Error #2000: No active security context.

I am using an imported class for a vimeo player in AS3, it is the official vimeo player api (vimeo.com). I want to handle any Security Errors that an instance of the class throws (they get thrown when the obect fails to load an external URL for a video). This is what I have got:

    var clipPlayer = new VimeoPlayer("5d22d3942a54d7c75b931bab4a911857", videoID[clickedClip], fullVideoWidth, fullVideoHeight, "10", 2);
    clipPlayer.addEventListener(SecurityErrorEvent.SECURITY_ERROR , vimeoError);

Later in the code ofcourse, I've got the function that handles the event:

    function vimeoError (e : SecurityErrorEvent) : void {
        trace("vimeo player failed to load");
    }

This all seems straight forward, but yet the Error Handler is not firing. I must be missing something here... Maybe you can't register this kind of event listener on a VimeoPlayer object. However, I am pretty certain it is the VimeoPlayer object throwing them. Here is an example of what I am getting:

Error opening URL 
'http://api.vimeo.com/moogaloop_api.swf?oauth_key=5d22d3942a54d7c75b931bab4a911857&clip_id=21185860&width=500&height=281&fullscreen=0&fp_version=10&api=1&cache_buster=565.7249609939754'
SecurityError: Error #2000: No active security context.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执笏见 2024-12-06 03:10:54

调度的错误事件与抛出的错误是分开的。在许多情况下,这两种情况都可能发生,然后您需要侦听前一种情况并在可能抛出的代码周围使用 try 语句捕获后者。您引用的错误似乎是抛出的错误(因为事件通常会字符串化为涉及方括号的内容)。

Dispatched error events are separate from thrown Errors. In many cases both kinds can occur, and then you need to listen for the former and catch the latter with a try statement around the code that may throw. The error you quote seems to be of the thrown variety (as events typically stringize to something involving square brackets).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文