将文件引用推送到向量中,添加事件侦听器以侦听每个文件引用的 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();
}
}
因此,此代码未经测试,还必须适应您的特定场景,但无论如何您都会明白这一点。