5 Replies Latest reply on Oct 24, 2016 1:04 AM by Philippe Infographiste

    jsfl - How do I change template publishing html of CANVAS file

    Philippe Infographiste

      Bonjour ,

      How can i change / import new HTML template by JSFL ?

      It isn't in the xml profile and i dont now how can i do, where can i search...

        • 2. Re: jsfl - How do I change template publishing html of CANVAS file
          Philippe Infographiste Level 1

          Thanks, but in this guide, i can't find how edit or import a new html template for CANVAS.

          I work with CC 2015.2 (Animate can have a html template)

           

          For example i can edit the profil by jsfl like that

           

          var doc = fl.getDocumentDOM();

          var folderPath=JSFLfolderPath(doc);

          var pPath = folderPath + "_Profile_.xml";

          doc.exportPublishProfile(pPath);

          xml = FLfile.read(pPath);

            

          // do something in the var xml

           

          FLfile.write(pPath, xml);

          doc.importPublishProfile(pPath);

           

           

          I have a lot of fla to convert in CANVAS, and all fla must have a custom html template.

          • 4. Re: jsfl - How do I change template publishing html of CANVAS file
            Nipun Asthana Adobe Employee

            Hi,

             

            There are a couple of new JSAPIs to import/export HMTL5 canvas publish template being used for a file.

            Here you go - Create HTML5 Canvas documents in Animate CC

                 bool document::exportCanvasPublishTemplate(pathURI)

                 bool document::importCanvasPublishTemplate(pathURI)

            • 5. Re: jsfl - How do I change template publishing html of CANVAS file
              Philippe Infographiste Level 1

              Great ! I could not find ...
              Really, thank you Nipun

               

              the answer is fl.getDocumentDOM().importCanvasPublishTemplate(pathURI);


              Here is a command that imports a template named "template.html" placed in the same directory as the FLA for all files folder filled.

               

              var fileMask = "*.fla";

              var fileList =new Array()

              var paths="";

              var ERROR=0;

              refDoc = "";

               

              var folderURI = fl.browseForFolderURL("Selectionnez le dossier contenant les FLA et le fichier template.html");

              var subFolder = confirm('Voulez-vous traiter aussi les sous-dossiers ?');

               

              if (folderURI){

                  listFile(folderURI+"/"); 

                 

                  if (fileList.length) {

                      var files = ""

                      for (var f=0;f<fileList.length;f++)        {

                          files += fileList[f].split("/").pop()+"\n";

                      }

                      if (confirm ("Executer la commande sur les fichiers suivants ?\n" + files))        {

                          for (var i=0;i<fileList.length;i++)            {

                              var doc = fl.openDocument(fileList[i]); 

                              var pathURI= folderURI+"/"+"template.html";

                              var exportFlag =fl.getDocumentDOM().importCanvasPublishTemplate(pathURI);

               

                              if(!exportFlag){

                                  fl.trace("Template could not be imported for "+fileList[f]);

                              }

               

                              doc.save(false);

                              doc.close(false);

                             

                          }

                      } else ERROR=1;

                  }

              }

               

              switch(ERROR){

                  case 0: alert ("Operation réussie.");

                  break;

                 

                  case 1: alert ("Operation annulée.");

                  break;

                 

                  case 2: alert ("Aucun fichier Flash trouve dans ce répertoire");

                  break;

              }

                 

              function listFile(paths){

                  var files=[]

                  var folds=[]

                  var files=FLfile.listFolder(paths +"/"+ fileMask,"files");

                 

                  for(i=0;i<files.length;i++)    {

                      fileList.push(paths+files[i]);

                  }

               

                  var folds=FLfile.listFolder(paths,"directories");

                 

                  if(subFolder){

                  for(var j=0;j<folds.length;j++)        {

                          listFile(paths+folds[j]+"/");

                      }

                  }

              }