Skip to main content
Participating Frequently
August 19, 2024
Question

JSFL create a new file from a template file

  • August 19, 2024
  • 2 replies
  • 523 views

Hi!

 

I need a jsfl command to create a new file from an .fla file that located in my app. Something like this:

 

fl.createDocument("htmlcanvas", "C:\Program Files (x86)\MyApp\FLATemplates\300x600.fla);

 I've searched for a long time but it seems like there aren't any command like this exist.

 

Any Ideas?

Thank you!!!

    This topic has been closed for replies.

    2 replies

    JoãoCésar17023019
    Community Expert
    August 19, 2024

    Hi.

     

    I think a workaround here would be to open the document and then convert it to the format that you want afterwards.
    https://github.com/AdobeDocs/developers-animatesdk-docs/blob/master/Document_object/docu6069.md

    Regards,

    JC

    YlazyAuthor
    Participating Frequently
    August 20, 2024

    Hi!

    var fileURI = "file:///C:/Users/...PC_300x600.fla";
    var doc = an.openDocument(fileURI);
    	doc.convertToDoc("", 'htmlcanvas', false);
    	doc = an.openDocument(fileURI);
    	doc.close(false);

    The code above did open the document then convert it. But it's not the expected behavior since Animate force me to save the new file. I need it to remain unsaved, just like when you use File > New from Template...

     

    Thank you!

    JoãoCésar17023019
    Community Expert
    August 20, 2024

    You need to provide a destination path to the convertToDoc method. Something like this:

    var newType = "htmlcanvas";
    var fileURI = FLfile.platformPathToURI("<platform_path_to_the_doc>");
    var doc = an.openDocument(fileURI);
    var destinationURI = doc.pathURI.slice(0, doc.pathURI.lastIndexOf("/")) + "/" + doc.name.slice(0, -4) + "_" + newType;
    
    doc.convertToDoc(destinationURI, newType, false);

     

    kglad
    Community Expert
    August 19, 2024

    if that existed it would be in the flfile methods.