Expressions can be extremely useful when creating automated fades in After Effects, since you’re able to modify start and stop times without needing to modify keyframes.
Start by creating an expression on your layer’s Opacity keyframe and setting an expression for how long you want the fade to last; setting this variable later allows you to easily make adjustments if needed – for example:
fadeTime =.33 This corresponds to approximately 1/3 of a second or 10 frames in a 29.97 composition.
After creating the variable for fade in and using linear expression, create another variable for fade out by creating another variable in which linear expression will be written as:
Linear(var, varMin, varMax, value1, value2)
Time will be our variable here since we’re looking at when layers start appearing. VarMin marks the exact time a layer appears (inPoint), with inPoint+fadeTime as our fade end point; value1 and 100 represent starting and ending opacities respectively.
Written out, it reads as follows:
fadeIn(time,inPoint,inPoint+fadeTime), 100;
Next, we set up a variable for fade out using another linear expression based on outPoint (since we are dealing with layer out point). VarMax refers to when fade begins; in this instance it means outPoint-fadeTime = when fade starts (outPoint-fadeTime = when it all started). Written out, this looks something like this:
FadeOut=linear(time, outPoint-fadeTime, 0, 100).
Finally, we combine both sets to generate our output:
fadeIn-FadeOut; As an expression, this would look something like this:
Faded Time =.33 and Fade In=linear(time, inPoint, fadeTime + fadeIn) between 100-250
fadeOut=linear(time,outPoint-fadeTime,0 100);
fadeIn-fadeOut; To alter the length of fade, alter numeric value.33 as desired. You can change starting and ending points for layers as necessary; when expression is added to layers, fade will adjust accordingly.