beautypg.com

Convert an expression to keyframes, The expression language, Accessing attributes and methods – Adobe After Effects CS4 User Manual

Page 661

background image

655

USING AFTER EFFECTS CS4

Expressions

Last updated 12/21/2009

Convert an expression to keyframes

In some situations, it’s useful to convert an expression to keyframes. For example, if you want to freeze the values in
an expression, you can convert the expression to keyframes and then adjust the keyframes accordingly; or, if an
expression takes a long time to evaluate, you can convert it to keyframes so that it renders more quickly. When you
convert an expression to keyframes, After Effects evaluates the expression, creating a keyframe at every frame, and then
disables the expression.

In the Timeline panel, select the property on which the expression is written and choose Animation

> Keyframe

Assistant > Convert Expression To Keyframes.

The expression language

The After Effects expression language is based on JavaScript 1.2, with an extended set of built-in objects. After Effects
uses only the core standard JavaScript 1.2 language, not the web browser–specific extensions. After Effects contains its
own set of extension objects—such as Layer, Comp, Footage, and Camera—that you can use to get most of the values
in an After Effects project.

Though the expression language is based on a scripting language, a subtle but important difference exists between a
script and an expression: Whereas a script tells an application to do something, an expression says that a property is
something.

For more information about JavaScript, see a JavaScript reference resource.

When creating expressions, keep in mind the following:

The value of an expression is the value of the last statement evaluated.

JavaScript is a case-sensitive language.

Semicolons are required to separate statements or lines.

Spaces between words are ignored, except within a string.

In JavaScript, a value stored in an object is called a property. However, After Effects uses the term property to refer to
layer components as defined in the Timeline panel. For this reason, After Effects refers to JavaScript properties as
either methods or attributes. In general practice, the difference between a method and an attribute is that a method
usually does something to create its output (return) value, whereas an attribute simply refers to an existing value to
determine its output (return) value. You can tell a method from an attribute most easily by looking for the parentheses
following the method name, which surround any input arguments to the method.

An object is an item that can contain other objects, attributes, and methods. Compositions, layers, and footage items
are examples of objects. Specifically, compositions, layers, and footage items are global objects, which means that they
can be referred to in any context without reference to some higher-level object.

Accessing attributes and methods

You use the expression language to access attributes and methods of layer properties. To access a value, use a chain of
object references separated by the period (

.

) operator. To chain object references past the layer level (for example, to

refer to effect properties, masks, or text animators), you can also use parentheses. For example, to link the Opacity
property in Layer A to the Blurriness property of the Gaussian Blur effect in Layer B, enter the following expression in
the expression field for the Opacity property for Layer A:

thisComp.layer("Layer B").effect("Gaussian Blur")("Blurriness")

This manual is related to the following products: