var sourceFile: File; var destination: File; //移动文件 function addData() { nowNum++; removeHdl(); if (nowNum >= totalNum) { LoadOver(); } else { sourceFile = data_arr[nowNum]; destination = new File(targetFileUrl); sourceFile.copyToAsync(destination, true); sourceFile.addEventListener(Event.COMPLETE, addData); sourceFile.addEventListener(IOErrorEvent.IO_ERROR, moveDataErr); } } private function moveDataErr(e1 = null, e2 = null) { removeHdl(); trace("复制失败:" + data_arr[nowNum].nativePath); addData(); } function removeHdl(e = null) { if (sourceFile) { sourceFile.removeEventListener(Event.COMPLETE, addData); sourceFile.removeEventListener(Event.COMPLETE, addData); sourceFile = null; } } function LoadOver(){ trace("全部完成") }