User Guide Cancel

Convert Animate projects to other document type formats

 

To convert your current document to any other document type, click File > Convert To and choose the desired document type. The following screenshot depicts the document conversion option from HTML5 canvas document type to other available formats.

List of allowed document types for conversion
List of allowed document types for conversion

HTML5 Canvas document type does not support multiple scenes. When you try to convert any multi-scene document to HTML5 Canvas document type, all the scenes are saved as separate files. Place all your scenes in separate symbols if you want to use them in a single document.

 You can convert your existing Animate projects to another format or reuse assets in a project by copying and pasting layers or library symbols.

Converting to other document types using JSAPI

If you have custom scenarios in which you want to convert files to other document types, then you can use the JSAPI. For example, converting many files at a time into other document types. 

convertToDoc method

Description

Usage

Parameters

Return value

Converts a document to expected document type.

document.convertToDoc(fileURI, doctype, fileClose)

fileURI A string, expressed as a file:/// URI, that specifies the path of the generated file after conversion.

docType A string value that specifies the required document type to be generated. To find document type, you can use document.type property. For example, fl.trace(fl.getDocumentDOM().type).

fileClose (optional) A Boolean value that specifies whether to close the generated file after conversion. Specifying true closes the generated file. The default is false.

A Boolean value.

True if document converted to expected document type successfully.

False otherwise.

Some of the sample scripts are provided below for your reference. You can copy the sample script in JSFL Script File document type, save the file, and execute it for better results. 

Converting all files from a folder to other document type

The following JSFL script converts all the fla files placed inside a folder to HTML5 Canvas doc.

var str = fl.scriptURI;
var url = str.substring(0, str.lastIndexOf("/"));
var folderURI = url + "/";
var fileMask = "*.fla";
var list = FLfile.listFolder(folderURI + "/" + fileMask, "files");
fl.trace(folderURI);
if (list) {
for(var i=0;i<list.length;i++)
{
var fileURI = folderURI + list[i];
var doc = fl.openDocument(fileURI);
fl.trace(folderURI);
doc.convertToDoc(folderURI+'Convertedfla'+i+'.fla',' htmlcanvas');
}
}
var str = fl.scriptURI; var url = str.substring(0, str.lastIndexOf("/")); var folderURI = url + "/"; var fileMask = "*.fla"; var list = FLfile.listFolder(folderURI + "/" + fileMask, "files"); fl.trace(folderURI); if (list) { for(var i=0;i<list.length;i++) { var fileURI = folderURI + list[i]; var doc = fl.openDocument(fileURI); fl.trace(folderURI); doc.convertToDoc(folderURI+'Convertedfla'+i+'.fla',' htmlcanvas'); } }
var str = fl.scriptURI;
var url = str.substring(0, str.lastIndexOf("/"));
var folderURI = url + "/";
var fileMask = "*.fla";
var list = FLfile.listFolder(folderURI + "/" + fileMask, "files");
fl.trace(folderURI);
if (list) {
for(var i=0;i<list.length;i++)
{   
 var fileURI = folderURI + list[i];
 var doc = fl.openDocument(fileURI);
 fl.trace(folderURI);
    doc.convertToDoc(folderURI+'Convertedfla'+i+'.fla',' htmlcanvas');

}
}

Converting latest active document to other document type

The following JSFL script converts the latest active document type file to HTML5 Canvas doc.

var str = fl.scriptURI;
var url = str.substring(0, str.lastIndexOf("/"));
var doc = fl.getDocumentDOM();
//doc.convertToDoc('url','htmlcanvas');
doc.convertToDoc(url +'/RotationCamera2.fla','htmlcanvas');
var str = fl.scriptURI; var url = str.substring(0, str.lastIndexOf("/")); var doc = fl.getDocumentDOM(); //doc.convertToDoc('url','htmlcanvas'); doc.convertToDoc(url +'/RotationCamera2.fla','htmlcanvas');
var str = fl.scriptURI;
var url = str.substring(0, str.lastIndexOf("/"));

var doc = fl.getDocumentDOM();
//doc.convertToDoc('url','htmlcanvas');
doc.convertToDoc(url +'/RotationCamera2.fla','htmlcanvas');

Converting all active documents to other document type

The following JSFL script converts all active documents to WebGL document type.

var str = fl.scriptURI;
var url = str.substring(0, str.lastIndexOf("/"));
for(var i=0;i<fl.documents.length;i++)
{
fl.trace(fl.documents[i].name);
fl.trace(fl.documents[i].type);
fl.documents[i].convertToDoc(url +'/abc'+i+'.fla','webGLDoc',true);
}
var str = fl.scriptURI; var url = str.substring(0, str.lastIndexOf("/")); for(var i=0;i<fl.documents.length;i++) { fl.trace(fl.documents[i].name); fl.trace(fl.documents[i].type); fl.documents[i].convertToDoc(url +'/abc'+i+'.fla','webGLDoc',true); }
var str = fl.scriptURI;
var url = str.substring(0, str.lastIndexOf("/"));

for(var i=0;i<fl.documents.length;i++)
{
 fl.trace(fl.documents[i].name);
 fl.trace(fl.documents[i].type);
 fl.documents[i].convertToDoc(url +'/abc'+i+'.fla','webGLDoc',true);
}

Browsing for a document and converting it into other document type

The following JSFL script searches for a specific string document type and converts it into AS3 document type. 

var fileURI = fl.browseForFileURL('open','open');
var doc = fl.openDocument(fileURI);
var sr = "";
sr +=fileURI;
var str = sr.substring(0, sr.lastIndexOf("/"));
doc.convertToDoc( str+"/test.fla" ,'Flash',true);
//doc.convertToDoc('fileURI','htmlcanvas',true);
//doc.convertToDoc('fileURI','WebGlDoc',true
var fileURI = fl.browseForFileURL('open','open'); var doc = fl.openDocument(fileURI); var sr = ""; sr +=fileURI; var str = sr.substring(0, sr.lastIndexOf("/")); doc.convertToDoc( str+"/test.fla" ,'Flash',true); //doc.convertToDoc('fileURI','htmlcanvas',true); //doc.convertToDoc('fileURI','WebGlDoc',true
var fileURI = fl.browseForFileURL('open','open');
var doc = fl.openDocument(fileURI);
var sr = "";
sr +=fileURI;
var str = sr.substring(0, sr.lastIndexOf("/")); 
doc.convertToDoc( str+"/test.fla" ,'Flash',true);
//doc.convertToDoc('fileURI','htmlcanvas',true);
//doc.convertToDoc('fileURI','WebGlDoc',true

Get help faster and easier

New user?