View comments | RSS feed

After Effects CS3  |  Go to CS4 Help

About expressions

When you want to create and link complex animations, but would like to avoid creating tens or hundreds of keyframes by hand, try using expressions. With expressions, you can create relationships between layer properties and use one property’s keyframes to dynamically animate other layers. For example, if you set Rotation keyframes for a layer and then apply the Drop Shadow effect, you can use an expression to link the Rotation property’s values with the Drop Shadow effect’s Direction values; that way, the drop shadow changes accordingly as the layer rotates. You can even use the pick whip to link path properties, so a mask can take its path from a brush stroke or a shape layer object.

Expressions are based on the standard JavaScript language, but you do not need to know JavaScript to use expressions. You can create expressions by using the pick whip or by copying simple examples and modifying them to suit your needs.

Note: Two great sources of example expressions are the Expression Sampler template project (File > Browse Template Projects) and the animation presets in the Behaviors category (Animation > Browse Presets).

You can do all of your work with expressions in the Timeline panel, though it is sometimes more convenient to drag the pick whip to a property in the Effect Controls panel. You can use the pick whip to create expressions, or you can enter and edit expressions manually in the expression field, a resizable text field in the time graph. The expression field appears alongside the property in layer bar mode; the expression field appears at the bottom of the Graph Editor in Graph Editor mode. You can write an expression in a text editor and then copy it into the expression field. When you add an expression to a layer property, a default expression appears in the expression field. The default expression essentially does nothing—it sets the property value to itself.

Expression interface in the Timeline panel in layer bar mode

A.
Enable Expression switch

B.
Show Post-Expression Graph button

C.
Pick whip

D.
Expression Language menu

E.
Expression field

While you are editing an expression, previews of all sorts are suspended; a red bar appears at the bottom of panels that are waiting for you to exit text-editing mode.

The values for a property that contains an expression appear in red or pink type.

Animation presets can include expressions, or even consist entirely of an expression. Animation presets that use expressions instead of keyframes are sometimes called behaviors.

After you add an expression to a property, you can continue to add or edit keyframes for the property. An expression can take the value of a property as determined by its keyframes and use that as input to generate new, modified values. For example, the following expression on a layer’s Position property preserves the layer’s keyframed motion and causes it to wiggle a little:

  transform.position.wiggle(10, 10)
Note: Using the wiggle expression is often much faster and easier than using the Wiggler.

If an expression cannot be processed, After Effects displays a message explaining the error and automatically disables the expression. A yellow warning icon  appears next to the expression; click the warning icon to view the error message again.

To show expressions that have errors, select one or more layers, right-click (Windows) or Control-click (Mac OS) a selected layer in the Timeline panel, and choose Reveal Expression Errors from the context menu.
Some expressions rely on the names of layers or properties in your project; if you change the name of a layer or property that is involved in an expression, After Effects will attempt to update the expression to use the new name. However, in some complex cases, After Effects will be unable to automatically update the expression, in which case the expression may produce an error message, and you must update the expression yourself.
Important: If you are running After Effects in a language other than the one for which an expression was written, or if you have changed the names of items (such as layers, effects, or other property groups), then the expression may not work until you modify the expression to use the new names or the strings that match the language in which you are running After Effects. Because the examples in this document were created for the default state of After Effects running in English, some examples in this document will not work without such modification.

Precomposing multiple layers will also cause expressions that refer to one of the layers’ properties to produce an error, requiring you to update these expressions to refer to the layer within the new composition. (See About nesting and precomposing.)

Note: The arguments for some After Effects effects have changed from those in previous versions. If you have existing expressions that use argument index references rather than argument names, you may need to update the expressions to use argument names.

When you are animating text, you can use the Expression selector to dynamically specify how much you want characters to be affected by an animator property through the use of expressions. You can add one or more Expression selectors to an animator group, and that animator group can contain one or more properties.




Comments

Comments are no longer accepted for After Effects CS3. After Effects CS4 is the current version. To discuss After Effects CS3, please use the Adobe forum.

Comments


Todd_Kopriva said on Dec 28, 2007 at 6:44 PM :
Jeff Almasol provides a script with which you can determine how to refer to any property in expressions:
http://www.redefinery.com/ae/view.php?item=rd_GimmePropPath

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/en_US/AfterEffects/8.0/WS3878526689cb91655866c1103906c6dea-7a37.html