Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Opacity change around a layer marker

  • Opacity change around a layer marker

  • Josh Hinckley

    May 11, 2020 at 7:41 pm

    Hi, I’m trying to fade out and back in (opacity 100 -> 0 -> 100) a layer based around markers. It works for the layer fading in, but it never fades out, it just cuts to 0 at the marker. I’ve played around with adjusting location of the in and out points and have gotten fade out to work, but then the fade in doesn’t. Any ideas? Thanks in advance.

    -josh

    n = 0;
    t = 0;
    if (thisLayer.marker.numKeys > 0){
    n = thisLayer.marker.nearestKey(time).index;
    if (thisLayer.marker.key(n).time > time) n--;
    }
    if (n > 0) t = thisLayer.marker.key(n).time;

    fadeFrames = 30;

    if (time < t)
    ease (time, t-framesToTime(fadeFrames/2), t, 100, 0)
    else
    ease (time, t, t+framesToTime(fadeFrames/2), 0, 100)

  • Dan Ebberts

    May 11, 2020 at 7:52 pm

    This should work:


    n = 0;
    fadeFrames = 30;
    tFade = framesToTime(fadeFrames)/2;

    if (marker.numKeys > 0){
    t = marker.nearestKey(time).time;
    if (time < t)
    ease (time, t-tFade, t, 100, 0)
    else
    ease (time, t, t+tFade, 0, 100);
    }else
    value

    Dan

  • Josh Hinckley

    May 11, 2020 at 8:01 pm

    That worked great, thanks for your time. Can you tell me where I was going wrong?

  • Dan Ebberts

    May 11, 2020 at 8:31 pm

    For one thing, you were using the code that finds the most recent, previous marker, not the nearest marker. The dead giveaway is this line:

    if (thisLayer.marker.key(n).time > time) n–;

    You do that if you want to trigger something at the most recent, previous marker, not if you want to center your action around the nearest marker.

    Dan

Viewing 1 - 4 of 4 posts

Log in to reply.

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