Search code examples
javascriptpythonflashadobe-animatefla

Convert many .fla files to .swf or .mov files at once


I have a folder with many FLA files (files.fla) in it.

I was wondering if there is a way to convert all those .fla files to .swf or .mov files at once (not opening each fla file in Adobe Animate and then export them to swf).

I'm also wondering if it is possible to achieve this using a Python script or maybe a JavaScript code being executed externally to Adobe Animate.

If someone has any idea or any links it would be helpful.


Solution

  • I have found a way to do it not externally.

    I post this in hope that it will help someone else struggling to find out how to do it within the software itself (Adobe Animate).

    Here's a snippest of the code doing that (that is not optimized).

    By the way it is really inspired by an answer on StackOverFlow (I do not remember the link).

    var swfFolder = 'Path/to/SWF/Files'​
    var flaFolder = fl.browseForFolderURL('Path/to/FLA/Files');​
    var folderContents = FLfile.listFolder(flaFolder);
    
    for(i = 0; i < folderContents.length; i++){​
    ​
       file = folderContents[i];​
       swfFilename = file.replace(".fla", ".swf");​
       file = 'Path/to/FLA/Files' + file;​
       fl.openDocument(file);​
       fl.getDocumentDOM().exportSWF(swfFolder + "/" + swfFilename, true);​
       fl.closeDocument(file);​
    
    }​
    
    

    It has some problems. The first time you execute this script, it will open a sort of browser file in order to choose the directory in which FLA files are located. and then pressing on ok for each file.

    But if you want just a script that does the export on a one file only, the code above will be helpfull:

    var swfFolder = 'Path/to/SWF/Files';
    var swfFilename = "exportedFile.swf";
    fl.getDocumentDOM().exportSWF(swfFolder + "/" + swfFilename, true);​
    
    

    In order to answer fully to my question (executing externally a code that exports FLA files to SWF files), we have to found out how to execute this script from a command line (cmd in Windows). Then to extend it to a folder of many files.fla, we can make a little Python code that calls the script on each file of the FLA directory.

    However, I didn't find how to achieve that. So if someone has the answer to that, please let us know.

    EDIT

    To call a JSFL script on a FLA file, use:

    Path\To\Animate.exe file.fla Path\To\file.jsfl

    (Link to the reference)

    When I had to make a Python script for that purpose, this whole command didn't work for me, I had to first open Adobe Animate with my fla file, wait some seconds (using time.sleep()) and then call the command

    Path\To\Animate.exe Path\To\file.jsfl