FileReference.download() 不起作用

发布于 2024-09-02 15:19:21 字数 980 浏览 9 评论 0原文

我正在构建一个 Flex 应用程序,它需要我下载文件。

我有以下代码:

public function execute(event:CairngormEvent) : void
{
    var evt:StemDownloadEvent = event as StemDownloadEvent;
    var req:URLRequest = new URLRequest(evt.data.file_path);
    var localRef:FileReference = new FileReference();

    localRef.addEventListener(Event.OPEN, _open);
    localRef.addEventListener(ProgressEvent.PROGRESS, _progress);
    localRef.addEventListener(Event.COMPLETE, _complete);
    localRef.addEventListener(Event.CANCEL, _cancel);
    localRef.addEventListener(Event.SELECT, _select);
    localRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _securityError);
    localRef.addEventListener(IOErrorEvent.IO_ERROR, _ioError);

    try {
        localRef.download(req);
    } catch (e:Error) {
        SoundRoom.logger.log(e);
    }
}

如您所见,我还连接了所有可能的事件侦听器。

执行时,我会出现浏览窗口,并且能够选择一个位置,然后单击“保存”。之后,什么也没有发生。

我将每个事件处理程序连接到我的记录器,但没有一个事件处理程序被调用!这里是不是少了点什么?

I'm building a Flex app which requires me to download files.

I have the following code:

public function execute(event:CairngormEvent) : void
{
    var evt:StemDownloadEvent = event as StemDownloadEvent;
    var req:URLRequest = new URLRequest(evt.data.file_path);
    var localRef:FileReference = new FileReference();

    localRef.addEventListener(Event.OPEN, _open);
    localRef.addEventListener(ProgressEvent.PROGRESS, _progress);
    localRef.addEventListener(Event.COMPLETE, _complete);
    localRef.addEventListener(Event.CANCEL, _cancel);
    localRef.addEventListener(Event.SELECT, _select);
    localRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _securityError);
    localRef.addEventListener(IOErrorEvent.IO_ERROR, _ioError);

    try {
        localRef.download(req);
    } catch (e:Error) {
        SoundRoom.logger.log(e);
    }
}

As you can see, I hooked up every possible event listener as well.

When this executes, I get the browse window, and am able to select a location, and click save. After that, nothing happens.

I have each event handler hooked up to my logger, and not a single one is being called! Is there something missing here?

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

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

发布评论

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

评论(1

灼疼热情 2024-09-09 15:19:21

问题似乎是我的命令在完成之前就被破坏了。

为了进行概念验证,我将 localRef 变量设置为静态变量而不是实例变量,一切都成功完成!我猜凯恩戈姆命令尽快自杀!

The problem seems to be with my command being destroyed before this could finish.

For a proof of concept, I set my localRef variable to be static instead of an instance variable, and everything went through successfully! I guess Cairngorm commands kill themselves asap!

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