Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Tristan Cossins on April 29, 2014 at 4:47 am

    Hey again,

    This is more out of curiosity than anything…

    I have applied some scale keyframes to selected layers using the following:

    var myScale = myLayer[i].property("scale");
    myScale.setValueAtTime(1,[100,100]);
    myScale.setValueAtTime(5,[130,130]);

    everything is all good but is it possible to code the easy ease keyframes that you get by hitting F9 in AE rather than the standard keyframes?

    any help/explanation would be much appreciated!

    Tristan Cossins replied 12 years, 3 months ago 2 Members · 3 Replies
  • 3 Replies
  • Xavier Gomez

    April 29, 2014 at 9:02 am

    Ease ease is still quite simple, other than that could be difficult to explain/manage…
    The KeyframeEase object requires 3 components (X,Y,Z), even in 2D, can’t figure out why.
    Also, you don’t need the speed, influence, easeIn, easeOut variables below, they are there just to tell the meaning of this things inside the parenthesis.

    Xavier.

    var BEZIER = KeyframeInterpolationType.BEZIER;
    var LINEAR = KeyframeInterpolationType.LINEAR;

    var speed, influence, easeIn, easeOut;
    var ease = new KeyframeEase(speed=0, influence=33.33333);
    var key1, key2;
    var myScale = app.project.activeItem.layer(1).property("scale");
    // set the values at times
    myScale.setValueAtTime(0,[0,0]);
    myScale.setValueAtTime(1,[100,100]);
    myScale.setValueAtTime(5,[130,130]);
    myScale.setValueAtTime(6,[0,0]);
    // get the key indices and set the rest
    key1 = myScale.nearestKeyIndex(1);
    key2 = myScale.nearestKeyIndex(5);
    myScale.setTemporalEaseAtKey(key1, easeIn=[ease, ease, ease], easeOut=[ease, ease, ease]);
    myScale.setTemporalEaseAtKey(key2, easeIn=[ease, ease, ease], easeOut=[ease, ease, ease]);

    // (optionnal) overwrite outter tangents (Bezier ---> Linear)
    myScale.setInterpolationTypeAtKey(key1, LINEAR, BEZIER);
    myScale.setInterpolationTypeAtKey(key2, BEZIER, LINEAR);

  • Tristan Cossins

    June 3, 2014 at 7:03 am

    Hi Xavier,

    Sorry for the late reply. I only just got around to testing this out today and it works perfectly.

    I’ve run into a bit of a problem though, my script actually has position keyframes aswell:

    var myPosition = myLayer[i].property(“position”);
    myPosition.setValueAtTime(1,[512,288]);
    myPosition.setValueAtTime(5,[512,288]);

    so I thought Id add on a couple of keys to the variable:

    var key1, key2, key3, key4;

    and then add this:

    key3 = myPosition.nearestKeyIndex(1);
    key4 = myPosition.nearestKeyIndex(5);
    myPosition.setTemporalEaseAtKey(key3, easeIn=[ease, ease, ease], easeOut=[ease, ease, ease]);
    myPosition.setTemporalEaseAtKey(key4, easeIn=[ease, ease, ease], easeOut=[ease, ease, ease]);

    however i get the following error:

    Unable to call ‘setTemporalEaseAtKey’ because of parameter 2. Value array does not have 1 elements.

    Any ideas?

  • Tristan Cossins

    June 3, 2014 at 7:24 am

    Gah, i just figured it out, it should’ve been:

    myPosition.setTemporalEaseAtKey(key3, easeIn=[ease], easeOut=[ease]);

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy