Flash CS4:我想用一个命令编译多个 fla,make 或 ant 是一个好的解决方案吗?

发布于 2024-08-27 00:39:28 字数 104 浏览 5 评论 0原文

我正在开发一个包含多个 swf 的大型 Flash CS4 项目,并希望整合我的构建过程。 ant/make 是否过度杀伤力或者有人在大型 Flash 项目中成功使用它们?

谢谢

I'm working on a large Flash CS4 project with multiple swfs and want to consolidate my build process. Are ant/make overkill or have people out there successfully used them on large Flash projects?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

爱冒险 2024-09-03 00:39:28

我使用 Ant 打开多个 .fla(已排队)并在其中运行 JSFL 命令。您可以使用此方法依次编译多个 fla,并清理一些属性。 (删除调试模式、删除类路径或替换过时的路径、引发标志等)

我在 100+ fla 上执行此操作。效果很好,但可能很慢。

下面是带有 JSFL 命令的 ANT 脚本示例。 (JSFL 使用参数来强制或不强制编译,即使 fla 没有修改)

<?xml version="1.0" encoding="utf-8" ?>

<property name="flash" value="C:\[Replace this]\Flash.exe"/>
<!-- we start from this model and do a build...jsfl-->
<property name="model_jsfl_path" value="${basedir}\jsfl\model_jsfl_clean_permit_debug.jsfl"/>

<property name="paths" value="C:/[target path containing nested fla..]/Flash/"/>
<property name="forceBuild" value="true"/> <!-- param given to jsfl -->

<loadfile property="model_jsfl" srcfile="${model_jsfl_path}">
    <filterchain> 
        <expandproperties/>
    </filterchain>
</loadfile>
<!--build...jsfl-->
<property name="jsfl_file" value="${basedir}\jsfl\build_xml_clean_permit_debug.jsfl"/>
<!-- we clear the file-->
<echo file="${jsfl_file}"></echo>
<!-- we apped the model_jsfl--> 
<echo file="${jsfl_file}" append="true">${model_jsfl}</echo>


<!-- This task launches the compileSWF.jsfl script to compile Assets.swf using the Flash IDE -->
<target name="compile" description="Compile the demo1 SWF with the Flash IDE">
    <echo>using model ='${model_jsfl_path}'</echo>
    <echo>using jsfl command ='${jsfl_file}'</echo>
    <echo>---build.xml completed---</echo>
    <exec executable="${flash}" failonerror="true">
        <arg line="${jsfl_file}" /> 
    </exec>
</target> 

这是 JSFL,它是我多年来发现/所做的东西的集合......

clearASOCache ( fl.configURI + "Classes/aso" );


var tempDoc=undefined;
if(fl.documents.length==0){
    //xmlPanel need a document, if there is none, create a temp document
    tempDoc=fl.createDocument();
}

//Put ${param1} here
//Remove whiteSpaces?
var paths = "${paths}";
var folders=paths.split("\r").join("").split("\n").join("");
folders=folders.split(",");
fl.trace(folders);
//Build folders roots array
for(var i=0;i<folders.length;i++){
    if(folders[i].substr(0,8)!="file:///"){
        folders[i]="file:///"+folders[i].split(":").join("|").split("\\").join("/");
        fl.trace("format:"+folders[i]);
    }
    if(folders[i].substr(folders[i].length-1,1)!="/"){
        folders[i]=folders[i]+"/";
    }
}
fl.trace("folders="+folders);

//Build exportlist array
exportlist=new Array();
for(var j=0;j<folders.length;j++){
    checkFolder(folders[j],exportlist);
}

//Go trough exportlist
var totaltime=0;
if(exportlist.length==0){
    fl.trace("No file need to publish.");
}else {
    fl.trace("exportlist="+exportlist.join("\n"));
    fl.trace("Start publishing...");
    for(var i=0;i<exportlist.length;i++){
        fl.trace("["+(i+1)+"/"+exportlist.length+"] "+exportlist[i].substr(exportlist[i].lastIndexOf("/")+1)+"\t@ "+exportlist[i].substr(0,exportlist[i].lastIndexOf("/"))+"");
        var t=exportswf(exportlist[i]);
        fl.trace("Completed in "+formatTime(t));
        totaltime+=t;
    }
    fl.trace("All done. Total time:"+formatTime(totaltime));
}





function clearASOCache( path ) {
  if (!FLfile.exists( path )) {
    fl.trace( path + "does not exist" );
    return;
  }
  FLfile.remove( path );
}
function formatTime(num){
    var h=Math.floor(num/3600000);
    num=num%3600000;
    var m=Math.floor(num/60000);
    if(m<10){
        m="0"+m;
    }
    num=num%60000;
    var s=Math.floor(num/1000);
    if(s<10){
        s="0"+s;
    }
    num=num%1000;
    return h+":"+m+":"+s+"."+num;
}
function exportswf(flapath,swfpath){
    var stime=new Date().getTime();
    var fla=fl.openDocument(flapath,true);
    if(swfpath==undefined){
        swfpath=flapath.substr(0,flapath.lastIndexOf("."))+".swf";
    }
    // call the method. In case there's
    // an error, trace it to the output window
    try {
        //replaceClassText("mx.flash.UIMovieClip","gm.flash.UIMovieClip");
        updateProfile(flapath);
    }catch(error){ 
        fl.trace(error); 
    }

    fla.exportSWF(swfpath,true);
    fla.close(false);
    var etime=new Date().getTime();
    return etime-stime;
}
function checkFolder(folder,list){
    fl.trace("folder="+folder);
    var flas=FLfile.listFolder(folder+"*.fla","files");
    for(var i=0;i<flas.length;i++){
        //fl.trace(flas[i]);

        var flatime=Number("0x"+FLfile.getModificationDate(folder+flas[i]));
        var swfname=flas[i].substr(0,flas[i].lastIndexOf("."))+".swf";
        var swftime=Number("0x"+FLfile.getModificationDate(folder+swfname));
        fl.trace(swfname+" "+flatime+" vs "+swftime);
        //$\{forceBuild}
        if(swftime<(flatime-100) || ("${forceBuild}" == "true")){
            list.push(folder+flas[i]);
            fl.trace(flas[i]);
        }
    }

    var flds=FLfile.listFolder(folder,"directories");
    for(var i=0;i<flds.length;i++){
        //fl.trace(i+" "+flds[i]+" of "+flds.length);
        checkFolder(folder+flds[i]+"/",list); 
    }
}
function updateProfile(flapath) {
    var xml, from, to, delta;
    // export the profile and read it in
    var pPath = flapath+".Profile.xml"; 
    fl.getDocumentDOM().exportPublishProfile(pPath);
    xml = FLfile.read(pPath);
    //fl.trace(xml);
    // override DebuggingPermitted to 0
    from = xml.indexOf("<DebuggingPermitted>");
    to = xml.indexOf("</DebuggingPermitted>");
    delta = xml.substring(from, to);
    xml = xml.split(delta).join("<DebuggingPermitted>0") 

    // write the modified profile and import it
    FLfile.write(pPath, xml);
    fl.getDocumentDOM().importPublishProfile(pPath);

    // save changes
    fl.saveDocument(fl.getDocumentDOM(), flapath);

    // delete the publish profile xml (no longer needed)
    FLfile.remove(pPath); 
} 

I use Ant to open multiple .fla (queued) and run JSFL command inside them. You could compile multiple fla one after another with this method and also clean some properties. (Remove debug mode, get rid of a classpath or replace an obsolete path, raise flag, etc.)

I do this on 100+ fla. Works great, but can be slow.

Here's an ANT script with a JSFL command has example. (The JSFL use a parameter to force or not force a compilation even if the fla was not modified)

<?xml version="1.0" encoding="utf-8" ?>

<property name="flash" value="C:\[Replace this]\Flash.exe"/>
<!-- we start from this model and do a build...jsfl-->
<property name="model_jsfl_path" value="${basedir}\jsfl\model_jsfl_clean_permit_debug.jsfl"/>

<property name="paths" value="C:/[target path containing nested fla..]/Flash/"/>
<property name="forceBuild" value="true"/> <!-- param given to jsfl -->

<loadfile property="model_jsfl" srcfile="${model_jsfl_path}">
    <filterchain> 
        <expandproperties/>
    </filterchain>
</loadfile>
<!--build...jsfl-->
<property name="jsfl_file" value="${basedir}\jsfl\build_xml_clean_permit_debug.jsfl"/>
<!-- we clear the file-->
<echo file="${jsfl_file}"></echo>
<!-- we apped the model_jsfl--> 
<echo file="${jsfl_file}" append="true">${model_jsfl}</echo>


<!-- This task launches the compileSWF.jsfl script to compile Assets.swf using the Flash IDE -->
<target name="compile" description="Compile the demo1 SWF with the Flash IDE">
    <echo>using model ='${model_jsfl_path}'</echo>
    <echo>using jsfl command ='${jsfl_file}'</echo>
    <echo>---build.xml completed---</echo>
    <exec executable="${flash}" failonerror="true">
        <arg line="${jsfl_file}" /> 
    </exec>
</target> 

Here's the JSFL, its an assembly of stuff I found/did over the years...

clearASOCache ( fl.configURI + "Classes/aso" );


var tempDoc=undefined;
if(fl.documents.length==0){
    //xmlPanel need a document, if there is none, create a temp document
    tempDoc=fl.createDocument();
}

//Put ${param1} here
//Remove whiteSpaces?
var paths = "${paths}";
var folders=paths.split("\r").join("").split("\n").join("");
folders=folders.split(",");
fl.trace(folders);
//Build folders roots array
for(var i=0;i<folders.length;i++){
    if(folders[i].substr(0,8)!="file:///"){
        folders[i]="file:///"+folders[i].split(":").join("|").split("\\").join("/");
        fl.trace("format:"+folders[i]);
    }
    if(folders[i].substr(folders[i].length-1,1)!="/"){
        folders[i]=folders[i]+"/";
    }
}
fl.trace("folders="+folders);

//Build exportlist array
exportlist=new Array();
for(var j=0;j<folders.length;j++){
    checkFolder(folders[j],exportlist);
}

//Go trough exportlist
var totaltime=0;
if(exportlist.length==0){
    fl.trace("No file need to publish.");
}else {
    fl.trace("exportlist="+exportlist.join("\n"));
    fl.trace("Start publishing...");
    for(var i=0;i<exportlist.length;i++){
        fl.trace("["+(i+1)+"/"+exportlist.length+"] "+exportlist[i].substr(exportlist[i].lastIndexOf("/")+1)+"\t@ "+exportlist[i].substr(0,exportlist[i].lastIndexOf("/"))+"");
        var t=exportswf(exportlist[i]);
        fl.trace("Completed in "+formatTime(t));
        totaltime+=t;
    }
    fl.trace("All done. Total time:"+formatTime(totaltime));
}





function clearASOCache( path ) {
  if (!FLfile.exists( path )) {
    fl.trace( path + "does not exist" );
    return;
  }
  FLfile.remove( path );
}
function formatTime(num){
    var h=Math.floor(num/3600000);
    num=num%3600000;
    var m=Math.floor(num/60000);
    if(m<10){
        m="0"+m;
    }
    num=num%60000;
    var s=Math.floor(num/1000);
    if(s<10){
        s="0"+s;
    }
    num=num%1000;
    return h+":"+m+":"+s+"."+num;
}
function exportswf(flapath,swfpath){
    var stime=new Date().getTime();
    var fla=fl.openDocument(flapath,true);
    if(swfpath==undefined){
        swfpath=flapath.substr(0,flapath.lastIndexOf("."))+".swf";
    }
    // call the method. In case there's
    // an error, trace it to the output window
    try {
        //replaceClassText("mx.flash.UIMovieClip","gm.flash.UIMovieClip");
        updateProfile(flapath);
    }catch(error){ 
        fl.trace(error); 
    }

    fla.exportSWF(swfpath,true);
    fla.close(false);
    var etime=new Date().getTime();
    return etime-stime;
}
function checkFolder(folder,list){
    fl.trace("folder="+folder);
    var flas=FLfile.listFolder(folder+"*.fla","files");
    for(var i=0;i<flas.length;i++){
        //fl.trace(flas[i]);

        var flatime=Number("0x"+FLfile.getModificationDate(folder+flas[i]));
        var swfname=flas[i].substr(0,flas[i].lastIndexOf("."))+".swf";
        var swftime=Number("0x"+FLfile.getModificationDate(folder+swfname));
        fl.trace(swfname+" "+flatime+" vs "+swftime);
        //$\{forceBuild}
        if(swftime<(flatime-100) || ("${forceBuild}" == "true")){
            list.push(folder+flas[i]);
            fl.trace(flas[i]);
        }
    }

    var flds=FLfile.listFolder(folder,"directories");
    for(var i=0;i<flds.length;i++){
        //fl.trace(i+" "+flds[i]+" of "+flds.length);
        checkFolder(folder+flds[i]+"/",list); 
    }
}
function updateProfile(flapath) {
    var xml, from, to, delta;
    // export the profile and read it in
    var pPath = flapath+".Profile.xml"; 
    fl.getDocumentDOM().exportPublishProfile(pPath);
    xml = FLfile.read(pPath);
    //fl.trace(xml);
    // override DebuggingPermitted to 0
    from = xml.indexOf("<DebuggingPermitted>");
    to = xml.indexOf("</DebuggingPermitted>");
    delta = xml.substring(from, to);
    xml = xml.split(delta).join("<DebuggingPermitted>0") 

    // write the modified profile and import it
    FLfile.write(pPath, xml);
    fl.getDocumentDOM().importPublishProfile(pPath);

    // save changes
    fl.saveDocument(fl.getDocumentDOM(), flapath);

    // delete the publish profile xml (no longer needed)
    FLfile.remove(pPath); 
} 
如此安好 2024-09-03 00:39:28

我现在正在使用 ant 进行一个项目,该项目需要将 10-20 个以上的独立组件编译到各自的 swf 中...还使用它来部署到临时和生产服务器。设置起来有点痛苦,但是一旦设置起来就非常容易,而且编译时间相对较快。此外,您可以完全自定义 ant 编译目标...例如,您可能只想在 90% 的时间内编译 10 个 swf 中的 3 个,因此您需要设置一个构建目标来执行此操作。在我看来,这绝对是值得的。祝你好运!

I'm using ant right now for a project that needs to compile upwards of 10-20 separate components into their own respective swfs... also using it to deploy to a staging and production server. It's kind of a pain to setup, but once it is it's really easy with relatively fast compile times. Additionally, you can totally customize ant compile targets... for example, you might only want to compile only 3 of the 10 swfs 90% of the time, so you'd setup a build target to do just that. In my opinion it's definitely worth it. Good luck!

七婞 2024-09-03 00:39:28

我有近 500 多个 FLA 文件,目前通过 ANT+JSFL 发布它们。我这里面临的问题是,FlashIDE在某个点崩溃,并且该点没有修复。但在发布全部文件中的一部分后,它肯定会崩溃。
如果有人在通过 ANT 和 JSFL 发布时发现任何类型的崩溃经历,我想听听。

I have almost more than 500 FLA files and currently publishing them through ANT+JSFL. The problem I am facing here is, FlashIDE crashes at a certain point and the point is not fixed. But it definitely crashes after publishing a part from the total lot of the files.
Would like to listen, if anyone is finding any sort of crash experience while publishing through ANT and JSFL.

赠佳期 2024-09-03 00:39:28

我使用 Visual Studio 的 Amethyst 插件。它不仅可以构建多个项目,还可以检测依赖关系并仅构建必要的项目。

I use the Amethyst plugin for Visual Studio. Not only will it build multiple projects, it can detect the dependencies and only build what is necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文