JSFL——很方便的批量发布工具(07-04-25改进版)

      Flash进修 2007-4-23 18:50

/**
功能:查找并发布指定目录及子目录下所有*.fla文件;
注意:Flash8.0以上版本可用;
警告:请勿尝试太大的目录(例如整个D盘),否则可能导致程序无法响应

*/
function getPath(){
        var folderPath = prompt("需要发布的文件夹:","");
 folderPath=folderPath.split("\\");
 folderPath = "file:///"+folderPath.join("/");
        if(folderPath.substr(folderPath.length-1,1)!="/"){
  folderPath=folderPath+"/";
 }
 return folderPath;
}
function getFiles(folderPath){
 var list=FLfile.listFolder(folderPath+"*.fla","files");
 return list;
}
function getFolders(folderPath){
 var list=FLfile.listFolder(folderPath+"*","directories");
 return list;
}
function getAllFiles(folderPath){
 var list= new Array();
 var childList= new Array();
 //查询当前目录的*.fla
 var temp=getFiles(folderPath);
 for(var i in temp){
  list.push(folderPath+temp[i])
 }
 //查询当前目录的子目录
 temp=getFolders(folderPath);
 for(var i in temp){
  childList=getAllFiles(folderPath+temp[i]+"/");
  for(var j in childList){
   list.push(childList[j]);
  }
 }
 return list;
}
function mytrace(list,name){
 name=name?name:"unknown"
 fl.trace("-----------"+name+"------------")
 for(var i in list){
  fl.trace("["+i+"]"+list[i]);
 }
 fl.trace("-----------"+"END"+"------------")
}
//----------------------------------------------------
fl.trace("//////////////////--START--//////////////////////");
//搜索所有*.fla的文件路径
var thePath=getPath()
var allFiles=getAllFiles(thePath)
//查看所有*.fla的文件路径
mytrace(allFiles,"allFiles");
//发布所有*.fla
if(allFiles.length>0){
var doit=prompt("确定要发布这些文件吗?(y/n)", "y");
if(doit=="y"){
 for (var i in allFiles){
  var file=allFiles[i];
  var flash_document = fl.openDocument(file);
  flash_document.publish();
  flash_document.close(true);
 }
}else{
 fl.trace("已取消发布");
}
}else{
 fl.trace("没有找到任何*.fla文件");
}

标签集:TAGS:flash扩展 jsfl 批量发布
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}