Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Fade up and Fade down at markers

  • Fade up and Fade down at markers

    Posted by Chris Craig on July 14, 2010 at 1:26 am

    Hi guys

    I have an expression that i do not know how to change to get the effect that i am after. What i would like is to fade a layer up over 3 frames at a layer marker, and then an the next layer marker fade it down over 2 frames. And this could continue on for each layer marker their after.

    The expression i have just turns the opacity on and off at each layer marker.

    Thanks alot

    Chris

    if (marker.numKeys) {
    // what's the nearest marker ?
    nearest_marker=marker.nearestKey(time)

    // if the nearestKey lies in the future,
    // subtract 1 to get the index of the 'current' key

    current_marker_index = 1 + nearest_marker.index - (nearest_marker.time > time);

    // convert our running marker index to
    (current_marker_index%2)*100

    } else {
    // degrade nicely if there are no markers:
    value;
    }

    Stephen Stangl replied 11 years, 9 months ago 3 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    July 14, 2010 at 3:19 am

    This should work:

    if (marker.numKeys > 0){
    m = marker.nearestKey(time);
    t = m.time;
    if (m.index%2){
    ease(time,t,t+3*thisComp.frameDuration,0,100)
    }else{
    ease(time,t,t+2*thisComp.frameDuration,100,0)
    }
    }else{
    value
    }

    Dan

  • Chris Craig

    July 15, 2010 at 5:11 am

    Dan

    Thank you very much for writing this for me. Only thing is, that the first keyframe that i make, makes the opacity of the vision before this first keyframe, 0. Is there any code that can make the first keframe 100% to this point and then fade down over the specified number of frames.

    Thanks Dan for your continued help.

    Chris

  • Chris Craig

    July 15, 2010 at 5:14 am

    Sorry Dan. i had asked for it initially, the wrong way around. What you gave me was correct for what i asked for, but i asked the wrong thing first. Sorry

  • Dan Ebberts

    July 15, 2010 at 5:37 am

    This should work:

    if (marker.numKeys > 0){
    m = marker.nearestKey(time);
    t = m.time;
    if (m.index%2){
    ease(time,t,t+2*thisComp.frameDuration,100,0)
    }else{
    ease(time,t,t+3*thisComp.frameDuration,0,100)
    }
    }else{
    value
    }

    You may need to switch the t+2 & t+3 in the ease() statements, depending on the timing you wanted for fade in vs. fade out.

    Dan

  • Chris Craig

    July 15, 2010 at 5:42 am

    Thank you Dan. it works perfectly.
    Thanks alot
    Chris

  • Stephen Stangl

    August 5, 2014 at 4:24 pm

    Hi Everyone,

    I am a total noob at expressions. I would like an expression very similar to the one Dan provided in this post, but I would like the opacity to change from 0 to 100 over 12 frames (f=12) at the first marker, 100 to 30 at the second marker, and 30 to 0 at the third marker.

    I am not sure how to write the condition for the if and else if part of the code, or if this is even the best way to write an expression that will accomplish my goal.

    Thanks!
    Steve

    if (marker.numKeys > 0){
    m = marker.nearestKey(time);
    t = m.time;
    f = 12;
    if ( ??? ){
    ease(time,t,t+f*thisComp.frameDuration,0,100)
    }else if ( ??? ) {
    ease(time,t,t+f*thisComp.frameDuration,100,30) }
    } else {
    ease(time,t,t+f*thisComp.frameDuration,30,0) }
    }else{
    value
    }

  • Dan Ebberts

    August 5, 2014 at 4:48 pm

    This should work:


    if (marker.numKeys > 2){
    m = marker.nearestKey(time);
    t = m.time;
    idx = m.index;
    f = 12;
    if ( idx == 1 ){
    ease(time,t,t+f*thisComp.frameDuration,0,100)
    }else if ( idx == 2 ) {
    ease(time,t,t+f*thisComp.frameDuration,100,30)
    } else {
    ease(time,t,t+f*thisComp.frameDuration,30,0)
    }
    }else{
    value
    }

    Dan

  • Stephen Stangl

    August 5, 2014 at 4:50 pm

    Wow! That was fast! Works like a charm. Thanks!

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