4 Replies Latest reply on Dec 12, 2015 12:12 AM by oliverIntergrafika

    Are there Javascript hooks to manipulate the timeline?

    strattonbrazil

      Is there an API for manipulating the timeline?  I didn't see anything about it in the JS API pdf, and after briefly scanning the object hierarchy in the toolkit, I didn't see it.  I'd like to be able to create new frames, jump to specific frames, remove frames, etc. 

        • 1. Re: Are there Javascript hooks to manipulate the timeline?
          pixxxel schubser MVP & Adobe Community Professional

          I think – only with script listener code.

           

          For example you can do  this:

           

          // go to frame number 2
          var jumpToFrameNumber = 2; // counts from 1
          
          var desc = new ActionDescriptor();
          var ref1 = new ActionReference();
          ref1.putIndex( stringIDToTypeID( "animationFrameClass" ), jumpToFrameNumber );
          desc.putReference( charIDToTypeID( "null" ), ref1 );
          executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
          
          // delete active frame
          var desc1 = new ActionDescriptor();
          var ref2 = new ActionReference();
          ref2.putEnumerated( stringIDToTypeID( "animationFrameClass" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
          desc1.putReference( charIDToTypeID( "null" ), ref2 );
          executeAction( charIDToTypeID( "Dlt " ), desc1, DialogModes.NO );
          

           

           

          Also you can do something like this:

           

          executeAction( stringIDToTypeID( "convertTimeline" ), new ActionDescriptor(), DialogModes.NO );
          // or
          //executeAction( stringIDToTypeID( "convertAnimation" ), new ActionDescriptor(), DialogModes.NO );
          
          // and this
          // the name say all
          executeAction( stringIDToTypeID( "animationFramesFromLayers" ), new ActionDescriptor(), DialogModes.NO );
          

           

           

          Have fun

           

          • 2. Re: Are there Javascript hooks to manipulate the timeline?
            strattonbrazil Level 1

            I've installed the script listener plugin and that seems to work great.  Thank you.  One question though.  How do I figure out commands the script listener won't normally listen for?  For example, I can add frames and select frames and see that in the log, but how can I figure out how many frames are already there? 

            • 3. Re: Are there Javascript hooks to manipulate the timeline?
              Michael L Hale Level 5

              I don't think there is a short easy way to explain how to work with Action Manager( other than mining the scriptlistener log ). And there isn't much offical documentaion on using Action Manager.

               

              Here is how to get the number of frames and the framerate.

              function GetFrameCount(){
                  var ref = new ActionReference();
                   ref.putProperty( charIDToTypeID( 'Prpr' ), stringIDToTypeID( "frameCount" ) );
                   ref.putClass( stringIDToTypeID( "timeline" ) );
                   var desc = new ActionDescriptor();
                   desc.putReference( charIDToTypeID( 'null' ), ref );
                   var resultDesc = executeAction( charIDToTypeID( 'getd' ), desc, DialogModes.NO );
                   
                   return resultDesc.getInteger( stringIDToTypeID( "frameCount" ) );
              };
              function GetFrameRate(){
                  var ref = new ActionReference();
                   ref.putProperty( charIDToTypeID( 'Prpr' ), stringIDToTypeID("documentTimelineSettings") );
                    ref.putClass( stringIDToTypeID( "timeline" ) );
                   var desc = new ActionDescriptor();
                   desc.putReference( charIDToTypeID( 'null' ), ref );
                   var resultDesc = executeAction( charIDToTypeID( 'getd' ), desc, DialogModes.NO );
              
                   return resultDesc.getDouble( stringIDToTypeID('frameRate') );
              };
              
              1 person found this helpful
              • 4. Re: Are there Javascript hooks to manipulate the timeline?
                oliverIntergrafika Level 2

                Hi Michael,

                 

                These functions (GetFrameCount(), GetFrameRate()) are working on Video Timeline only. Is there a similar solution for Frame Animation?

                 

                Thanks a lot!