Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JSFL create a new file from a template file

Explorer ,
Aug 19, 2024 Aug 19, 2024

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!!!

415
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2024 Aug 19, 2024

if that existed it would be in the flfile methods.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2024 Aug 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 19, 2024 Aug 19, 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 20, 2024 Aug 20, 2024
LATEST

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);

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines