为什么调度 Event.OPEN 而不是 IOErrorEvent.IO_ERROR?

发布于 2024-12-27 06:59:58 字数 605 浏览 5 评论 0原文

为什么当 SWF 为在网络服务器上以及尝试加载无效 URL 时?

在本地运行 SWF 时,情况并不相同。

示例代码:

var CLS_UrlStream:URLStream = new URLStream(); // Initialize URLStream class instance.
CLS_UrlStream.addEventListener(Event.OPEN, FUN_StreamHandler); // Listen for successful connections.
CLS_UrlStream.addEventListener(IOErrorEvent.IO_ERROR, FUN_StreamHandler); // Listen for conenction errors.
CLS_UrlStream.load(new URLRequest("InvalidURL")); // Load file.

private function FUN_StreamHandler(FUN_PAR_Event:Event):void {
trace("EVENT TYPE: " + FUN_PAR_Event.type);
}
// Outputs: EVENT TYPE: open

Why does the load method of the URLStream class dispatch Event.OPEN instead of IOErrorEvent.IO_ERROR when the SWF is on a webserver and when trying to load an invalid URL?

The same doesn't apply when running the SWF locally.

Sample code:

var CLS_UrlStream:URLStream = new URLStream(); // Initialize URLStream class instance.
CLS_UrlStream.addEventListener(Event.OPEN, FUN_StreamHandler); // Listen for successful connections.
CLS_UrlStream.addEventListener(IOErrorEvent.IO_ERROR, FUN_StreamHandler); // Listen for conenction errors.
CLS_UrlStream.load(new URLRequest("InvalidURL")); // Load file.

private function FUN_StreamHandler(FUN_PAR_Event:Event):void {
trace("EVENT TYPE: " + FUN_PAR_Event.type);
}
// Outputs: EVENT TYPE: open

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

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

发布评论

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

评论(2

一生独一 2025-01-03 06:59:58

Event.OPEN 在加载时被触发。所以永远都会被调用。

您可能需要 HTTPStatusEvent.HTTP_STATUS

Event.OPEN gets triggered on load. So will always be called.

You probably want HTTPStatusEvent.HTTP_STATUS

清醇 2025-01-03 06:59:58

当SWF 在服务器上运行并请求不存在的资源时,服务器实际上会发送一条错误消息,该消息算作数据,因此不存在错误事件。这在本地并不适用,因为当请求不存在的文件时,没有 Web 服务器会响应错误。通过使用 Monster Debugger 进行实时跟踪发现了这一点。

When the SWF is running on the server and is requesting for a resource that doesn't exist, the server actually sends an error message which counts as data, thus there is no error event. The same didn't apply locally because there was no web server to respond with an error when a request for an nonexistent file is made. Discovered this by tracing live with the Monster Debugger.

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