Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions how to connect only 1 of multiple keyframes to a slider control?

  • how to connect only 1 of multiple keyframes to a slider control?

    Posted by Emmett Fraser on October 24, 2016 at 1:01 am

    I apologize in advance if this is a dumb question. My experience so far is limited to pick whipping values to slider controls. Really basic stuff. But I’ve run into a problem where I want something to animate from 0 to x (as determined by the slider) and pick-whipping just ain’t gonna cut it anymore.

    How would I write the expression to make the first keyframe consistent, and the next keyframe link to the slider?

    To give a specific example, I have a path with a stroke. I know that I want the stroke width to begin at 2 and end at 2, but I would like the value in the middle to be controlled by a slider. ie. key1 = 2, key2 = x, key3 = 2.

    Thanks in advance! Any help would be greatly appreciated!

    Emmett Fraser replied 9 years, 6 months ago 2 Members · 3 Replies
  • 3 Replies
  • Jorge Froberg

    October 24, 2016 at 9:31 am

    This should work. Put this expression on the Stroke Width value.
    What it does is it will tell AE to only use the slider value between 2 and 3 seconds. Outside of that range it will use your normal keyframes.
    Hope it helps.

    if (time >= 1 && time <= 3) {
    effect("Slider Control")("Slider");
    } else {
    content("Rectangle 1").content("Stroke 1").strokeWidth;
    }

  • Emmett Fraser

    October 24, 2016 at 5:41 pm

    Thanks Jorge, I’ll give this a try!

  • Emmett Fraser

    October 25, 2016 at 9:47 pm

    Hey Jorge, just wanted to let you know where I ended up. Your snippet was really helpful to get me started and send me down the right path. Once I got yours working I wanted to change it so that the timing of the change could be controlled by a marker on the layer.

    After a lot of trial and error I ended up with this!

    I pasted the code in the Stroke Width property and made a slider called “spark width”.

    Anyways, thanks for your help!

    time_to_marker = Math.abs(time - thisLayer.marker.nearestKey(time).time)*5
    easeOut(time_to_marker,comp("_controller").layer("Controller").effect("spark width")("Slider"),2)

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