You may have wished for the ability to temporarily disable keyframes in After Effects. Your wish is granted via the simplest possible expression: a static value.
Close-Up: Creative Accounting
There are, of course, workarounds to the limitations of expressions. The commonly used Levels effect, for example, has an Individual Controls version that was created expressly (pun intended) for use with expressions.
For sampling sound, Trapcode (www.trapcode.com) offers Sound Keys, which can translate waveforms into numerical data suitable for expressions.
As for such unreachable data as mask vertices, scripting, not expressions, is capable of interacting with their values. Although scripting and expressions use the same language, there is at present no way to call a script with an expression.
Where would you use this? Let's say that you have an element whose Opacity is keyframed to 0% at its starting frame of an animation. Or perhaps you want to adjust an element to match the rest of a scene at a time when it is out of frame. The idea is to temporarily change the property value without touching the keyframes.
Open 10_basicExpression.aep and look at the composition called bouncing ball for expression. A Tint effect has been added that turns the ball red each time it hits the floor. Suppose that you wish to disable this effect temporarily without deleting its keyframes altogether.
Begin by revealing Tint (with the layer highlighted, press E to reveal effects or U for all keyframed properties) and set an expression for the Amount to Tint property. To do this, you can use Animation > Add Expression or its keyboard shortcut (Alt+Shift+=/Option+Shift+=), but the most direct method is to Alt-click (Option-click) the stopwatch of the property that requires the expression.
A few changes occur as the result of setting an expression (Figure 10.1). A new line is revealed below the Amount to Tint property that reads Expression: Amount to Tint. A button whose icon looks like an equals sign appears to the right, highlighted; this Enable Expression toggle activates and deactivates the expression. The other icons come into play a little later. Over in the main area of the Timeline (Graph Editor off for now), the text effect("Tint")(3) is automatically highlighted, and a cursor blinks to the right of this text, indicating that you can edit it by typing.
Figure 10.1. The expression is activated by Alt-clicking on the stopwatch. The value for Amount to Tint is now displayed in red, and a second line appears containing the Expression controls; the expression text itself appears in the main area of the Timeline and is highlighted until you click elsewhere.
The default expression effect("Tint")(3) tells After Effects to look at the layer's effects for the one called Tint and to use the value of its third property (Amount to Tint). Simply applying an expression changes nothing about where the value comes from.
Now write your own expression by typing a number. Replace effect("Tint")(3) with 100 and either press Enter (not Return) or just click outside the text area. Amount to Tint now uses this one value, 100, on every frame of the composition (Figure 10.2). The keyframes have effectively been "frozen" or "muted" (whichever term you prefer), replaced with a constant value.
Figure 10.2. If a numerical property contains keyframes, entering a number in the expressions field overrides those keyframes with the specified value. The flat white line along the top of the Graph Editor demonstrates what's going on, relative to the gray lines below showing the previous animated values.
This example is admittedly a bit esoteric for the sake of simplicity; situations in which I've found this technique useful include removing transforms from an element I want to color correct, and holding opacity at 100% for an element that is blinking or animating at a nearly invisible level in the scene.
Toggling the Expressions button (that equals sign in the expression controls) enables and disables the keyframes. What could possibly go wrong here? Why, you could forget to disable or delete (Alt/Option-click on the stopwatch) the expression when you're done and want the animated values to render. That's about it.
Things do get a little more complex with properties that contain more than one value, such as Position. These are called arrays and are detailed in the next section.
Linking Animation Data