Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions keyframe to Linear

  • keyframe to Linear

    Posted by Ilya Sire on January 16, 2017 at 6:26 pm

    Hello forum,

    i found this thread here https://forums.creativecow.net/thread/227/18998
    i have 2 keyframes on other layer (null)
    and apply this expression to other layer opacity

    how i can maintain last value to 0

    currently this code set back to 100.
    Please help. Thank you

    ilya

    p=thisComp.layer("null").effect("keyframe")("Slider") // two keyframes
    v = 100;

    if (p.numKeys > 0){
    n = p.nearestKey(time).index;
    if (p.key(n).time > time) n--;
    if (n > 0 && n < p.numKeys)
    v = linear(time,p.key(n).time,p.key(n+1).time,100,0); // it get back to 100 after time past last keyframe??
    }
    v

    Ilya Sire replied 9 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    January 16, 2017 at 6:53 pm

    This should work:


    p=thisComp.layer("null").effect("keyframe")("Slider") // two keyframes
    v = 100;

    if (p.numKeys > 0){
    n = p.nearestKey(time).index;
    if (p.key(n).time > time) n--;
    if (n > 0){
    if (n < p.numKeys){
    v = linear(time,p.key(n).time,p.key(n+1).time,100,0);
    }else{
    v = 0;
    }
    }
    }
    v

    Dan

  • Ilya Sire

    January 17, 2017 at 3:28 am

    Thank you for helping me… it worked!

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