Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression value to a keyframe

  • Expression value to a keyframe

    Posted by Vera Steinbeck on March 7, 2019 at 12:24 pm

    hi there!
    yesterday i searched for a good way to give my first keyframe a value and my second keyframe another value.

    logical (for me) it would be like this:
    s = thisComp.layer("control").effect("example")("example");
    key(1).value = 0;
    key(2).value = s;

    but i found a solution in this forum where it was told that i have to go via keytime, like this:
    (had to put it to the end of the post)

    the second code works fine, buti think, this is far to complicated to solve my problem.
    does anybody have a better approach to this?
    ????

    max = thisComp.layer("control").effect("example")("example");
    min = 0;
    t1 = key(1).time;
    t2 = key(2).time
    if (time<=t1) min;
    else if (time>t1 && time<t2) ease(time,t1,t2,min,max);
    else max;

    Vera Steinbeck replied 7 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Alex Printz

    March 7, 2019 at 4:31 pm

    You cannot push values into keys, only pull. You would do like this:


    t1 = key(1).time;
    t2 = key(2).time;

    v1 = 0;
    v2 = thisComp.layer("control").effect("example")("example");

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

    note that you cannot adjust the curves with this; you are only looking at when these keys are set.

    If you want to be able to adjust the slope, set the keys to have different property values (e.g, Key 1: 100, key 2:200), and try this:


    p1 = key(1).value;
    p2 = key(2).value;

    v1 = 0;
    v2 = thisComp.layer("control").effect("example")("example");

    linear(value,p1,p2,v1,v2)

    Note this second expression depends on the keys having different input property values and understanding that your property is going to convert the change in property values into a similar change between your two defined values!

    Alex Printz
    Mograph Designer

  • Vera Steinbeck

    March 11, 2019 at 2:28 pm

    thank you alex!

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