Can we export from flash to createjs from the command line?

你。 提交于 2019-12-08 08:10:30

问题


I am looking for a way to automate the task of running the toolkit for flash for createjs from the command line.

I have a lot of individual components and I would like to export them in a batch process. Can this be done?


回答1:


Your best bet for automation would be to use jsfl. The following script, modified from this thread prompts for a target folder and output folder, then automates the process of opening *.fla files and publishing them via the CreateJS publisher when executed. One caveat is that the CreateJS panel has to be open in Flash already (though there may be a way to do this too).

It is also worth noting that you can just as easily modify this code to either hardcode the path's you need, or read up on the JSFL Docs or dynamically load a manifest file. You can execute them from a batch as well if you really want to run it from a command line.

exporter.jsfl

var folderURI = fl.browseForFolderURL("Please select the folder you want to recurse");
var outputURI = fl.browseForFolderURL("Please select the output path");

var allFlas = FLfile.listFolder(folderURI + "/" + "*.fla", "files");
for(var i = 0; i < allFlas.length; i++)
{
    var flaName = allFlas[i];

    var doc = fl.openDocument(folderURI + "/" + flaName);
    var targetName = doc.name.replace(".fla","");
    var cjsDataKey = "CreateJSToolkit_data";
    //var data = doc.getDataFromDocument(cjsDataKey);
    var data = [
            "version", "0.6",
            "exportHTML", "true",
            "frameBounds", "false",
            "includeHiddenLayers", "false",
            "soundsPath", "sounds/",
            "preview", "false",
            "imagesPath", "images/",
            "libraryPath", "libs/",
            "compactPaths", "false",
            "exportSounds", "true",
            "imagesNS", "images",
            "exportLibs", "true",
            "libNS", "lib_" + targetName.toLowerCase(),
            "hostedLibs", "true",
            "exportImages", "true",
            "outputPath", outputURI,
            "createjsNS", "createjs"
    ];
    doc.addDataToDocument(cjsDataKey, "string", data.join("\n"));
    doc.save();
    doc.close(false);
    // Re-open document so that Publish for CreateJS panel picks up changes.
    doc = fl.openDocument(folderURI + "/" + flaName);
    fl.runScript(fl.configURI + "Commands/Publish for CreateJS.jsfl");
    // Insert an artificial pause here. Seems to be necessary for Toolkit publish.
    alert("Complete!");
    doc.close(false);
}


来源:https://stackoverflow.com/questions/20622499/can-we-export-from-flash-to-createjs-from-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!