Conditionals and Triggers
Also called If/Then statements, conditionals open up extra possibilities by allowing you to use any circumstance
that expressions can recognize—pretty much any numerical or Boolean state anywhere in the Timeline—as 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
Here’s 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;
you’ll 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)
Here’s what’s 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 author’s vanity). How do you know it’s a marker
and which one it is? The variable’s 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 it’s easy to forget
it even exists. It has five (count ’em) arguments, all required, that identify, in order, the