Skip to main content
Participating Frequently
September 29, 2023
Answered

Publish all open files using JSFL script problem

  • September 29, 2023
  • 3 replies
  • 952 views

Hi, I'm trying to get a jsfl script to run in Animate 23.0.2 through Run Command... that will publish all open files. The script I'm using is below. My problem is that it only will publish the open tab file, but it does it in every open file's directory. So, I end up with one file's published files in all the directories. 

function export_all(){ 
    var docs=an.documents;
    var docs_length=docs.length;
    for (var i=0; i<docs_length; i++) {  
        var doc = docs[i];
        doc.publish();
    }
}

export_all();
    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    It's not an ideal solution, but it worked for both AS3 and HTML5 Canvas documents.

     

    var docs = fl.documents;
    var docIndex, doc;
    
    for (docIndex in docs)
    {
    	doc = docs[docIndex];
    	fl.setActiveWindow(doc);
    	doc.publish();
    }

    3 replies

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    September 29, 2023

    It's not an ideal solution, but it worked for both AS3 and HTML5 Canvas documents.

     

    var docs = fl.documents;
    var docIndex, doc;
    
    for (docIndex in docs)
    {
    	doc = docs[docIndex];
    	fl.setActiveWindow(doc);
    	doc.publish();
    }
    Participating Frequently
    September 29, 2023

    Yes, one of my team just came up with a similar solution:

     

     

    for (var i = 0; i < fl.documents.length; i++) {
    
        an.setActiveWindow(fl.documents[i]);
    
        an.getDocumentDOM().publish();
    
    }

     

    Thank you for your help.

    JoãoCésar17023019
    Community Expert
    Community Expert
    September 29, 2023

    Hi.

     

    Both scripts work for me.

     

    Can you provide more details?

     

    Regards,

    JC

    Participating Frequently
    September 29, 2023

    Yes, I made some new test files and placed them in new directories. I renamed the JSFL and put that in a new directory. I'm running macOS Ventura and Animate 23.0.2.
    I took some screen shots.

    Directories before running the JSFL script:

     

    Animate with files open. Banner_File_1.fla being the current tab.



    Directories after running the JSFL:

    kglad
    Community Expert
    Community Expert
    September 29, 2023

    @Todd31479318hnlq 

     

    so, is there a problem?

    kglad
    Community Expert
    Community Expert
    September 29, 2023

    try:

     

    for (doc in fl.documents) {
    fl.documents[doc].publish();
    }

    Participating Frequently
    September 29, 2023

    Thanks for the reply. I tried your solution and it has the same behavior as the script I posted, it publishes only the current tab document to all the open document's directories.

    kglad
    Community Expert
    Community Expert
    September 29, 2023

    not for me.  all fla's open in animate publish.

     

    create a new directory 

    save your jsfl to that new directory with a new name.

    retest.