flash 批量编译发布fla 文件

因为需要编译上百个fla文件,了解了一下利用jsfl批量编译fla文件的方法,找到了老外的一个例子:http://www.veryinteractivepeople.com/?p=80

fla2swf_Batch.jsfl:

var tempDoc=undefined;
if(fl.documents.length==0){
    tempDoc=fl.createDocument();
}
xui = fl.getDocumentDOM().xmlPanel(fl.configURI + "Commands/AutoConvertToFlash9.xml");
if(tempDoc){
    fl.closeDocument(tempDoc);
}
var exportlog="";
if(xui.dismiss=="accept"){
    var searchSubDir=xui.searchSubDir;
    var folder=xui.path;
    if(folder.substr(0,8)!="file:///"){
        folder="");
    }
    if(folder.substr(folder.length-1,1)!="/"){
        folder=folder+"/";
    }
}
exportlist=new Array();

checkFolder(folder,exportlist,searchSubDir);

var totaltime=0;
if(exportlist.length==0){
    alert("No file need to publish.");
}else{
    if(confirm(exportlist.length+" files will be updated and published")){
        for(var i=0;i<exportlist.length;i++){
            setPublishProfileSettings(exportlist[i]);
            //FLfile.write("

file:///c:/exportlog.txt", exportlog);//uncomment if you want to log all files
        }
    }
}

function checkFolder(folder,list,checkSub,pre){
    if(pre==undefined){
        pre="";
    }
    var flas=FLfile.listFolder(folder+"*.fla","files");
    for(var i=0;i<flas.length;i++){
        list.push(folder+flas[i]);
    }
    if(checkSub=="true"){
        var flds=FLfile.listFolder(folder,"directories");
        for(var i=0;i<flds.length;i++){
            checkFolder(folder+flds[i]+"/",list,checkSub,pre+" ");
        }
    }
}

function setPublishProfileSettings(fileURI)
{
       if (fl.fileExists(fileURI))
        {
            var xml, from, to, delta;

            var doc=fl.openDocument(fileURI);

            var fileName = fileURI.split("/").pop();
            var folderPath = fileURI.split(fileName)[0];
            fileName = fileName.split(".")[0];

            var pPath = folderPath + "/_Profile_.xml";
            fl.getDocumentDOM().exportPublishProfile(pPath);
            xml = FLfile.read(pPath);

            var swfpath=fileName+".swf";
            from = xml.indexOf("<flashFileName>");
            to = xml.indexOf("</flashFileName>");
            delta = xml.substring(from, to);
            xml = xml.split(delta).join("<flashFileName>"+swfpath);

            from = xml.indexOf("<Version>");
            to = xml.indexOf("</Version>");
            delta = xml.substring(from, to);
            xml = xml.split(delta).join("<Version>9");

            from = xml.indexOf("<ActionScriptVersion>");
            to = xml.indexOf("</ActionScriptVersion>");
            delta = xml.substring(from, to);
            xml = xml.split(delta).join("<ActionScriptVersion>3");


            from = xml.indexOf("<AS3PackagePaths>");
            to = xml.indexOf("</AS3PackagePaths>");

            delta = xml.substring(from, to);
            var classPath = "./";
            if (fileName.indexOf("/") > -1)
            {
                classPath = "";
                var splitPath = fileName.split("/");
                splitPath.length--;
                var i = splitPath.length;
                while (i--)
                {
                    classPath += "../";
                }
            }

            xml = xml.split(delta).join("<AS3PackagePaths>" + classPath + "classes");

            FLfile.write(pPath, xml);
            fl.getDocumentDOM().importPublishProfile(pPath);

            fl.saveDocument( doc);
            fl.getDocumentDOM().publish();

            FLfile.remove(pPath);
            fl.closeDocument(doc);
            exportlog+="updated and exported " + fileURI+"\r\n";
        }
}

 

AutoConvertToFLash9.xml:


<dialog buttons="accept, cancel"  title="Enter path of Flash files to publish" >
 <vbox>
   <checkbox id="searchSubDir" label="Search Sub Directory" checked="true"/>
   <label value="Path to publish:" />
   <textbox value="D:\autopublish" id = "path" size="100" multiline="true"/>
 <vbox>

</dialog>

配置:


  • Extract the script, and place the script and the GUI under “Documents and Settings/[Your login id]/Local Settings/Application Data/Macromedia/[Your flash version]/[language]/Configuration/Commands/”
  • Run flash, you will see a new command named “AutoConvertToFlash9″ in the command menu.
  • Run the script, everything else should be obvious

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值