ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Opacity change around a layer marker

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Josh Hinckley
Opacity change around a layer marker
on May 11, 2020 at 7:41:42 pm
Last Edited By Josh Hinckley on May 11, 2020 at 7:47:45 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 &lt; t)
ease (time, t-framesToTime(fadeFrames/2), t, 100, 0)
else
ease (time, t, t+framesToTime(fadeFrames/2), 0, 100)


Return to posts index

Dan Ebberts
Re: Opacity change around a layer marker
on May 11, 2020 at 7:52:07 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



Return to posts index

Josh Hinckley
Re: Opacity change around a layer marker
on May 11, 2020 at 8:01:56 pm

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


Return to posts index


Dan Ebberts
Re: Opacity change around a layer marker
on May 11, 2020 at 8:31:00 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



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]