Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Slider Value Expression Linked to Single Keyframe

  • Slider Value Expression Linked to Single Keyframe

  • Sam Caino

    June 2, 2017 at 2:18 am

    Hi Folks,

    I want to control a slider value with a number in a text layer. The below expression works in my composition. However, I want to keyframe it so the first keyframe is zero and the second keyframe corresponds to the value set by the text layer in the expression (“Number”).

    Is there any way to modify this expression so it only attaches to the second keyframe, leaving my first keyframe value set to zero?

    txt=thisComp.layer("Number").text.sourceText;
    if (! isNaN(parseFloat(txt)))
    parseFloat(txt)
    else
    value

  • Dan Ebberts

    June 2, 2017 at 1:03 pm

    If they are linear keyframes, and there are only two of them, something like this should work:


    txt=thisComp.layer("Number").text.sourceText;
    val = parseFloat(txt);
    if (numKeys > 1 && (! isNaN(val)))
    linear(time,key(1).time,key(2).time,key(1).value,val)
    else
    value

    Dan

  • Otto Tasnadi

    November 22, 2019 at 12:47 pm

    Hey, I want to use the same expression but I want the numbers to be rounded. Can you give me some tips on this? thanks!

  • Dan Ebberts

    November 22, 2019 at 5:25 pm

    Like this maybe:


    txt=thisComp.layer("Number").text.sourceText;
    val = parseFloat(txt);
    if (numKeys > 1 && (! isNaN(val)))
    v = linear(time,key(1).time,key(2).time,key(1).value,val)
    else
    v = value;
    Math.round(v)

    Dan

  • Otto Tasnadi

    November 25, 2019 at 1:20 pm

    Thanks a lot!

Viewing 1 - 5 of 5 posts

Log in to reply.

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