Conditionals and Triggers
Also called If/Then statements, conditionals open up extra possibilities by allowing you to use any circumstance
that expressions can recognizepretty much any numerical or Boolean state anywhere in the Timelineas a
condition for an event or a series of events to occur.
Triggers often use conditional statements; they wait for a specific event to occur and use this to trigger another
event. The possible uses for triggers are seemingly endless.
Trigger a Dissolve
Heres a simple trigger that needs no conditonal statement: A composition marker triggers a one-second filmic
dissolve (this will work equally well with layer markers). This expression could just as easily be set up to trigger
a different operation, such as a simple opacity fade to black or white, but once you understand the basics, you
can adapt it however you like.
A project containing a dissolve and a fade to black, each using the expression described here, can be
found on your disc as 10_dissolve.aep.
A layer marker can be set by highlighting a layer and pressing * at the frame where the marker should appear.
You can use this shortcut to set a marker interactively while looping a RAM Preview.
Add the Levels (Individual Controls) effect to the layer. Reveal controls for Input Black and Output White;
youll apply the same expression to each, with the variation that they will animate in opposition. The expression
for Input Black is
mark = marker.key(1).time;
linear(time, mark, mark+1, 1, 0)
Close-Up: The Dissolve
A fade to black is typically accomplished either by reducing Opacity of a source layer (or layers) from
100% to 0% over time, or by fading up a single black solid layer from 0% to 100% over time. This very
linear transition lacks the visual interest of a true film dissolve, which can have various characteristics
depending on the type of film stock and so on, but which takes on more interest by fading in a nonlinear
fashion. This section teaches you how to use an expression to do whatever you want, and for free
throws in a simple technique to mimic the response of a film dissolve. As is shown beginning in the
next chapter, lowering exposure in 32-bpc HDR naturally behaves like a film dissolve.
The inversion for Output White is
mark = marker.key(1).time;
linear(time, mark, mark+1, 0, 1)
Heres whats happening. This is the first example in this chapter of a variable. This one is called mark, named
for the fact that it identifies a marker (and in expression of the authors vanity). How do you know its a marker
and which one it is? The variables argument tells you; the marker portion signifies a layer marker, key(1)
specifies the first one, and time specifies the time at which that marker occurs.
The linear(t, tMin, tMax, value1, value2) command is so compact and efficient that its easy to forget
it even exists. It has five (count em) arguments, all required, that identify, in order, the
Time that the effect evaluates
Time to start a linear transition
Time to end a linear transition
Value at the start
Value at the end
You can apply an expression directly from the Effect Controls panel by Alt/Option-clicking on the
stopwatch, the same way you would in the Timeline panel. This can be convenient because the property
with the expression is revealed in the Timeline as well, where you can edit the expression.
Each expression first evaluates the current time (time). When that time reaches mark (marker 1), After Effects
performs a linear transition from 0 (0%) to 1 (100%), and the transition lasts one second (until mark + 1,
or one second past marker 1). The result is visible in the Graph Editor and the composition itself (Figures
10.19a and b).
Figures 10.19a and b. Expressions are set for Input Black and Output White (a). Note
how the look differs from a simple fade to black (b). Although it’s difficult to spot in
a printed figure, the highlights become richer while the blacks deepen, as opposed to
the entire image turning gray.

Get Adobe After Effects 7.0 Studio Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.