Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression instead of 3 keyframes?

  • Expression instead of 3 keyframes?

    Posted by Dmitry Yershov on May 2, 2014 at 1:39 pm

    Hi,

    I need an expression that basically does the same thing as keyframes – changes position value at a specific time. I need 3 “keyframes”. Then I want to switch between several expressions like that with a slider. Is this possible?

    Thank you!

    Kevin Camp replied 12 years ago 2 Members · 3 Replies
  • 3 Replies
  • Kevin Camp

    May 2, 2014 at 10:45 pm

    you could use three actual keyframes and a valueAtTime() expression linked to the slider you described…

    first, create the 3 position keyframes. then add this expression to the position property:

    slider = effect("Slider Control")("Slider");
    n = Math.max(1,Math.min(slider,numKeys));
    valueAtTime(key(Math.floor(n)).time)

    if you’d rather enter in position values, you could type them into an array and use this expression:

    slider = effect("Slider Control")("Slider");
    posArray = [[100,100], [300,300], [500,500]];
    n = Math.max(0,Math.min(slider,posArray.length-1));
    posArray[n]

    the position values can be in 3 dimensions [x,y,z] if needed.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Dmitry Yershov

    May 3, 2014 at 11:02 pm

    Thanks, that works, but it only changes 1 keyframe at a time. Is it possible to change 3 or more specific keyframes with each slider value?

    Thank you!

  • Kevin Camp

    May 5, 2014 at 4:46 pm

    do you want to connect several keyframed properties of the same layer to a slider on the same layer (like position, scale, etc.) or connect several keyframed properties of different layers to the same slider?

    if it is properties on the same layer, then the same expression should work, but you’d need to have the expression on each property.

    if you needed properties on multiple layers, then you may want to move the slider to a separate layer, like a null layer. this isn’t required, but it means the expression will be the same for each layer then you’ll need to direct the expression to that layer by adding this line to the expression, changing the layer name to your slider layer:

    ctrl = thisComp.layer(“Null 1”);

    then modify the next line in the expression to use the ctrl layer:

    slider = ctrl.effect(“Slider Control”)(“Slider”);

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

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