4 Replies Latest reply on Apr 16, 2013 5:06 AM by alexandre.imbert

    name an png sequence

    alexandre.imbert Level 1

      hi evry one

       

      i m exporting a png sequence from a "charcater" on  the scene which has many state. ("idle", "action","jump")

       

      i'd like to name a png sequence and that it takse the name of either the label or the name of the graphic clip on the scene.

      is it possible ?

        • 1. Re: name an png sequence
          moccamaximum Level 5

          Yes. The Following script will export a png sequence accroding to the framelabels you gave your animation.

          For example if you have frame 1 labeled as "idle" and in the same timeline frame 10 labeled as "action".

          It will output: idle_0.png; idle_1.png ...idle_9.png;action_10.png......

           

          Open your fla document with the animation in the timeline window.

           

          Cretae a new Jsfl file: File>New>FlashJavascriptFile

           

          insert this code in the jsfl file:

           

          var doc = fl.getDocumentDOM();

          var lyrs = doc.getTimeline().layers;

           

          var len = lyrs.length;

          var totalframes;

          var lyr;

          var i;

          var pngName;

          var saveName;

          var curLabel;

          var tl = doc.getTimeline();

           

          var saveDir = fl.browseForFolderURL("Choose a folder in which to save your exported PNGs:");

          if (saveDir) {

           

              for (i=0; i < len; i++) {

                  lyr = lyrs[i];

                  totalframes = lyrs[i].frameCount;

                  for (j=0;j<totalframes;j++){

                      if(lyr.frames[j].name !=""){

                         curLabel = lyr.frames[j].name;

                      }

                      exportPng(j);

                      //this advances the playhead

                      tl.setSelectedFrames(j,j+1);

                  }

              };

          }

           

          function exportPng(j) {

              pngName = saveDir + "/" + curLabel + "_"+j+".png";

              doc.exportPNG(pngName, true, true);

              fl.trace("Exported: " + pngName);

          }

           

          //code was inspired by this post

           

          Click on the RunScript icon (|>).

           

          Flash will ask you where to save your exported sequence.

           

          Choose a directory.

           

          Click OK.

           

          If Flash is ready you will find your files in the specified directory.

          • 2. Re: name an png sequence
            alexandre.imbert Level 1

            Thanks moccamaximum ! this is great !

            i'll offer you a mocca one day if you come around paris

            • 3. Re: name an png sequence
              moccamaximum Level 5

              i'll hold you to that

              • 4. Re: name an png sequence
                alexandre.imbert Level 1

                For any reader who might come around :

                note that This script counts the number of layers you made in your fla. important to notice that