Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Control 2nd keyframe with slider

  • Control 2nd keyframe with slider

    Posted by Will Bartlett on January 4, 2023 at 8:08 am

    Hi all,

    I’m working on a lower thirds MOGRT that has a shape layer and a text layer.

    On the shape layer, I have a slider setup that has two keyframes to animate the shape layer from left to right on the x axis. The first keyframe has a value of 0 and I would like to control the 2nd keyframe using another slider, so I have created a Null layer and added another slider to it.

    Is it possible to use the slider control on the Null to control only the 2nd keyframe’s value on the shape layers slider?

    If so, what would the expression look like, and where would I put it since the slider control on the shape layer already has key frames, meaning I can’t add an expression to it (or can I? lol)

    The goal is to be able to control the width of the shape layer so that it can be extended to match whatever text is entered. I do have other expressions to make it automatically extend, but for this specific AE project, I have the size/position/anchor points parameters already being used, so without complicating it more, I think figuring out how to control the 2nd keyframe would be easiest.

    Thanks in advance for any help or suggestions!!

    Will Bartlett replied 3 years, 8 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    January 4, 2023 at 8:50 am

    Yes, you can add an expression to a keyframed property, but the expression has to supply the property’s value at all frames, not just at a particular keyframe. You might be able to achieve the desired result, especially if the keyframes are linear, or you’re willing to accept the easing provided by ease(), easeIn(), or easeOut() expressions. However, it gets trickier if you need to preserve some custom easing.

  • Dan Ebberts

    January 4, 2023 at 8:03 pm

    So, for the linear keyframe case it could look like this:

    t1 = key(1).time;
    t2 = key(2).time;
    v1 = key(1).value;
    v2 = thisComp.layer("Null 1").effect("Slider Control")("Slider");
    linear(time,t1,t2,v1,v2)

    Or, you might want to change the last line to this:

    easeOut(time,t1,t2,v1,v2)

    Hopefully, that gives you the idea.

  • Will Bartlett

    January 4, 2023 at 9:02 pm

    Amazing! Thank you Dan for your help (you make this community thrive)!

    To complete the animation, I have the lower thirds animating out with another two keyframes at the end of the comp (Duplicates of the first two keyframes then time-reversed)

    Keyframes 1 and 4 are the same, and keyframes 2 and 3 are the same. If anyone else needs the code for this; here’s what I ended up with after Dan’s help above to get more than the 2 key frames to work:

    t1 = key(1).time;

    t2 = key(2).time;

    t3 = key(3).time;

    t4 = key(4).time;

    v1 = key(1).value;

    v2 = thisComp.layer("control").effect("Slider Control")("Slider");

    v3 = thisComp.layer("control").effect("Slider Control")("Slider");

    v4 = key(4).value;

    if (time < t2) {

    ease(time, t1, t2, v1, v2);

    } else {

    ease(time, t3, t4, v3, v4);

    }

  • Dan Ebberts

    January 4, 2023 at 9:13 pm

    Try it this way:

    t1 = key(1).time;
    t2 = key(2).time;
    t3 = key(3).time;
    t4 = key(4).time;
    v1 = key(1).value;
    v2 = thisComp.layer("control").effect("Slider Control")("Slider");
    v3 = thisComp.layer("control").effect("Slider Control")("Slider");
    v4 = key(4).value;
    if (time < t3)
    ease(time,t1,t2,v1,v2)
    else
    ease(time,t3,t4,v3,v4)
  • Will Bartlett

    January 4, 2023 at 9:14 pm

    haha I edited my response after figuring it out while you were responding to me; looks like I came to roughly the same conclusion. Appreciate your reply and initial help – THANK YOU!

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