Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Keyframe triggers a fade out

  • Keyframe triggers a fade out

    Posted by Jeff Bobbington on January 14, 2016 at 11:08 am

    Hey all,

    I know this is a simple one but I just cant get it to work.

    Id like to have the opacity to instantly jump up to 100% when an (unrelated) keyframe on a slider is met, then fade out over 20f. If another keyframe happens to interrupt this fadeout then it should still do the same thing, jump up to 100% and fade out. (over and over again). So the resting opacity should be 0% until keyframes are met, sort of like a flashbulb effect when keyframes are met.

    Jeff Bobbington replied 10 years, 6 months ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    January 14, 2016 at 2:50 pm

    This should work:


    fadeTime = framesToTime(20);
    s = effect("Slider Control")("Slider");
    if (s.numKeys > 0){
    n = s.nearestKey(time).index;
    if (time < s.key(n).time) n--;
    if (n > 0)
    linear(time - s.key(n).time,0,fadeTime,100,0)
    else
    0;
    }else
    0

    Dan

  • Jeff Bobbington

    January 14, 2016 at 3:53 pm

    Perfection as usual Dan!
    Greatly appreciated.

  • Jeff Bobbington

    January 15, 2016 at 12:57 pm

    Greatly appreciated!

    How could I go about adding 2 variables to this:

    A delay time – so instead of triggering on the exact frame, it happens a few frames before or after the keyframe is met.

    A fade in duration – so it can take more than 1 frame to go from 0 to 100% opacity.

  • Dan Ebberts

    January 15, 2016 at 5:43 pm

    Maybe like this:


    fadeInTime = framesToTime(5);
    fadeOutTime = framesToTime(15);
    delay = framesToTime(3);

    s = effect("Slider Control")("Slider");
    if (s.numKeys > 0){
    n = s.nearestKey(time).index;
    if (time < s.key(n).time) n--;
    if (n > 0){
    t = time - s.key(n).time - delay;
    if (t < fadeInTime)
    linear(t,0,fadeInTime,0,100)
    else
    linear(t,fadeInTime,fadeInTime+fadeOutTime,100,0);
    }else{
    0;
    }
    }else
    0

    Dan

  • Jeff Bobbington

    January 18, 2016 at 12:40 pm

    Very cool!
    I have found an issue though.

    If I set the delay to a negative number so as to advance the flash effect, it cuts off the fadein effect.
    So a delay of -15 together with a fade of 15 results in the fade being completely cut off!

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