Skip to main content
Participating Frequently
December 11, 2017
Answered

Script to automate a repetitive task in Animate?

  • December 11, 2017
  • 1 reply
  • 4526 views

Hi everybody

In the past, Flash/Animate was used in our company to create illustrations (99% of which static illustrations with no animations at all). Time has come to convert these 600+ illustrations to Illustrator (Animate CC -> .svg -> Illustrator CC).

Is there a way to automate the process "publish as svg" in Animate using a script?

Thanks a lot for your ideas.

Paul

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    So here we go!

    Just run the 'fla_to_svg.jsfl' script by going to 'Commands > Run Command...' or just dragging over to the Animate IDE.

    Then the script will prompt you to choose the folder where the FLAs are located.

    Now you just have to wait. Just pay attention that if some document asks you for missing fonts, you are going to have to dismiss the popup manually - you can check "Don't show again.".

    Optionally, there is another script called 'export_publish_profile.jsfl' that you can use to change the SVG publish settings if you wish.

    All you have to do is to open any FLA, go to File > Publish Settings..., configure the way you want things and then run the script to get the current settings and export to the 'fla_to_svg.xml'. Notice that in this way you can use the script to export the FLA to anything, not just SVG.

    Scripts download: fla_to_svg.jslf.

    'fla_to_svg.jsfl' code:

    fl.outputPanel.clear();

    function exportToSVG()

    {

        var uri = fl.browseForFolderURL("select", "Select the folder containing the FLAs.");       

        var files = FLfile.listFolder(uri + "/*.fla", "Files.");

        var total = files.length;

       

        try

        {

            for (var i = 0;i < total; i++)

            {

                var profileIndex;

               

                fl.openDocument(uri + "/" + files);           

                profileIndex = fl.getDocumentDOM().importPublishProfile(fl.scriptURI.replace(".jsfl", ".xml"));           

                fl.getDocumentDOM().currentPublishProfile = fl.getDocumentDOM().publishProfiles[profileIndex];

                fl.getDocumentDOM().publish();

                fl.getDocumentDOM().deletePublishProfile();

                fl.getDocumentDOM().close(false);

            }

        }

        catch(error)

        {

            fl.trace(files);

            fl.trace(error);

            fl.trace("___________");

        }

    }

    exportToSVG();

    'export_publish_profile.jsfl' code:

    fl.outputPanel.clear();

    function exportPublishProfile()

    {

        fl.getDocumentDOM().exportPublishProfile(fl.scriptURI.replace("export_publish_profile.jsfl", "fla_to_svg.xml"));

    }

    exportPublishProfile();

    I hope it helps and don't hesitate to ask if you have any further question.

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    December 11, 2017

    Hi.

    Do you need to export each FLA as a SVG?

    What I mean is if there is only one artwork in each FLA or it's possible that each FLA has more than one artwork in differente scenes and frames.

    If you provide some more details, I can help you.

    Regards,

    JC

    Participating Frequently
    December 11, 2017

    Hi JC

    Thanks for your quick response :-)

    Yes, I do have to export the entire repository of FLA files as SVG files (about 600 FLA in total). This is the reason why I am looking for a method to automate the task, rather than opening every single FLA manually and publishing it as SVG. What I require at the end of the day is an SVG file from each FLA file

    The idea behind this is to use Illustrator CC from now on for updating the existing illustrations (former FLA files) and for creating new illustrations.

    Thanks, Paul

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    December 11, 2017

    So here we go!

    Just run the 'fla_to_svg.jsfl' script by going to 'Commands > Run Command...' or just dragging over to the Animate IDE.

    Then the script will prompt you to choose the folder where the FLAs are located.

    Now you just have to wait. Just pay attention that if some document asks you for missing fonts, you are going to have to dismiss the popup manually - you can check "Don't show again.".

    Optionally, there is another script called 'export_publish_profile.jsfl' that you can use to change the SVG publish settings if you wish.

    All you have to do is to open any FLA, go to File > Publish Settings..., configure the way you want things and then run the script to get the current settings and export to the 'fla_to_svg.xml'. Notice that in this way you can use the script to export the FLA to anything, not just SVG.

    Scripts download: fla_to_svg.jslf.

    'fla_to_svg.jsfl' code:

    fl.outputPanel.clear();

    function exportToSVG()

    {

        var uri = fl.browseForFolderURL("select", "Select the folder containing the FLAs.");       

        var files = FLfile.listFolder(uri + "/*.fla", "Files.");

        var total = files.length;

       

        try

        {

            for (var i = 0;i < total; i++)

            {

                var profileIndex;

               

                fl.openDocument(uri + "/" + files);           

                profileIndex = fl.getDocumentDOM().importPublishProfile(fl.scriptURI.replace(".jsfl", ".xml"));           

                fl.getDocumentDOM().currentPublishProfile = fl.getDocumentDOM().publishProfiles[profileIndex];

                fl.getDocumentDOM().publish();

                fl.getDocumentDOM().deletePublishProfile();

                fl.getDocumentDOM().close(false);

            }

        }

        catch(error)

        {

            fl.trace(files);

            fl.trace(error);

            fl.trace("___________");

        }

    }

    exportToSVG();

    'export_publish_profile.jsfl' code:

    fl.outputPanel.clear();

    function exportPublishProfile()

    {

        fl.getDocumentDOM().exportPublishProfile(fl.scriptURI.replace("export_publish_profile.jsfl", "fla_to_svg.xml"));

    }

    exportPublishProfile();

    I hope it helps and don't hesitate to ask if you have any further question.

    Regards,

    JC