处理 AS3 中的安全错误
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调度的错误事件与抛出的
错误
是分开的。在许多情况下,这两种情况都可能发生,然后您需要侦听前一种情况并在可能抛出的代码周围使用 try 语句捕获后者。您引用的错误似乎是抛出的错误(因为事件通常会字符串化为涉及方括号的内容)。Dispatched error events are separate from thrown
Error
s. In many cases both kinds can occur, and then you need to listen for the former and catch the latter with atry
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).