Chain FileReference.save

我正在创建一个思维导图Flash应用程序,它必须保存导入到单个文件夹中的所有图像,以及用于数据存储的xml。虽然我的当前应用程序在未嵌入HTML时有效,但一旦由于安全违规而立即中断。 通过单击保存按钮,代码循环遍历图像数组并为每个图像创建FileReference,并调用FileReference.save来保存图像。 如本文档所述,每次保存都需要通过UI交互触发: http://kb2.adobe.com/cps/405/kb405546.html 但它也表明可以通过从同一个函数调用它们来进行一系列保存。 但是,使用我的图像数组循环,只保存第一个图像,并且没有为后续图像调用弹出窗口。我的猜测是,一次只允许一个原生弹出窗口,但我该怎么做呢?有没有人尝试过链接文件引用?     
已邀请:
将文件引用推送到向量中,添加事件侦听器以侦听每个文件引用上的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();
    }
}
因此,此代码未经测试,也必须根据您的具体情况进行调整,但无论如何您都会得到这个想法。     

要回复问题请先登录注册