链文件Reference.save

发布于 2024-10-29 20:00:39 字数 471 浏览 4 评论 0原文

我正在创建一个思维导图 Flash 应用程序,该应用程序必须保存导入到单个文件夹中的所有图像以及用于数据存储的 xml。虽然我当前的应用程序在未嵌入 HTML 时可以正常工作,但一旦出现安全违规,它就会崩溃。

通过单击“保存”按钮,代码将循环遍历图像数组并为每个图像创建一个 FileReference,并调用 FileReference.save 来保存图像。

如本文档所述,每次保存都需要由 UI 交互触发: http://kb2.adobe.com/cps/405/kb405546.html

但它也指出可以通过从同一函数调用它们来进行一系列保存。

但是,使用我的图像数组循环,仅保存第一个图像,并且不会为后续图像调用弹出窗口。我的猜测是一次只允许一个本机弹出窗口,但我将如何去做呢?以前有人尝试过链接文件引用吗?

I'm in the process of creating a mindmap flash app which has to save all images that are imported into a single folder, along with an xml for data storage. While my current app works when not embedded in a HTML, it breaks as soon as it is due to security violations.

By clicking a save button, the code loops through the array of images and creates a FileReference for each of them and calls FileReference.save to save the image.

As stated in this documentation, each save needs to by triggered by UI interaction:
http://kb2.adobe.com/cps/405/kb405546.html

But it also states a chain of saves can be made by calling them from the same function.

However using my images array loop, only the first image gets saved and no popup is being called for subsequent images. My guess is that only one native popup at a time is allowed, but how would I go about doing this? Has anyone tried chaining filereferences before?

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

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

发布评论

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

评论(1

遇见了你 2024-11-05 20:00:39

将文件引用推送到向量中,添加事件侦听器以侦听每个文件引用上的 Event.COMPLETE 回调。然后,在回调中,将文件引用从数组中弹出,并调用cue中的下一个。

var myFiles:Vector.<FileReference> = new Vector.<FileReference>();

//Populate the vector (this example assumes you can figure this out

//While populating the vector, add the event listener to the file reference for the COMPLETE event.
myRef.addEventListener(Event.COMPLETE, onFileSaved);
myFiles.push(myRef);

private function onFileSaved(e:Event):void
{
    var i:int = 0;
    for(i; i < myFiles.length; ++i){
        if(myFiles[i] == FileReference(e.currentTarget)){
            FileReference(e.currentTarget).removeEventListener(Event.COMPLETE, onFileSaved);
            myFiles.splice(i, 1);
        }
    }

    if(myFiles.length > 0){
        FileReference(myFiles[0]).save();
    }
}

因此,此代码未经测试,还必须适应您的特定场景,但无论如何您都明白了。

Push the file references into a vector, add the event listener to listen for the Event.COMPLETE callback on each file reference. Then, inside the callback, pop the file reference out of the array and call the next one in cue.

var myFiles:Vector.<FileReference> = new Vector.<FileReference>();

//Populate the vector (this example assumes you can figure this out

//While populating the vector, add the event listener to the file reference for the COMPLETE event.
myRef.addEventListener(Event.COMPLETE, onFileSaved);
myFiles.push(myRef);

private function onFileSaved(e:Event):void
{
    var i:int = 0;
    for(i; i < myFiles.length; ++i){
        if(myFiles[i] == FileReference(e.currentTarget)){
            FileReference(e.currentTarget).removeEventListener(Event.COMPLETE, onFileSaved);
            myFiles.splice(i, 1);
        }
    }

    if(myFiles.length > 0){
        FileReference(myFiles[0]).save();
    }
}

So this code is un-tested and will also have to be adapted to your specific scenario but you get the idea anyway.

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