Edit an expression manually – Adobe After Effects CS4 User Manual
Page 656

650
USING AFTER EFFECTS CS4
Expressions
Last updated 12/21/2009
Edit an expression manually
1
Click in the expression field to enter text-editing mode.
Note: When you enter text-editing mode, the entire expression is selected. To add to the expression, click within the
expression to place the insertion point; otherwise, you will replace the entire expression.
2
Type and edit text in the expression field, optionally using the Expression Language menu.
To see more of a multiline expression, drag the bottom or top of the expression field to resize it.
3
To exit text-editing mode and activate the expression, do one of the following:
•
Press Enter on the numeric keypad.
•
Click outside the expression field.
Example: Use the expression language reference to write an expression
Follow along with this example to learn how to use the After Effects expression language reference to write expressions.
The expression created in this example links the Position property of Solid 2 to the Position property of Solid 1, with
the movement of Solid 2 offset by 2 seconds from the movement of Solid 1.
1
Create two solid layers: Solid 1 and Solid 2.
2
Animate the Position property values for Solid 1 using keyframes. (See “
About animation, keyframes, and
3
Select the Position property for Solid 2 and choose Animation
> Add Expression or Alt-click (Windows) or
Option-click the stopwatch
button for the property. The following expression appears by default:
transform.position
4
Type the following directly over
transform.position
:
thisComp
5
The element
thisComp
is a global attribute whose value is a Comp object representing the current composition. To
determine what can follow
thisComp
in your expression, look up the return value for
thisComp
under “
objects, attributes, and methods (expression reference)
Note that
thisComp
returns a Comp object. Next, look at “
Comp attributes and methods (expression reference)
on page 667 to see which attributes and methods you can use with a Comp object. One option is
layer(index)
.
The index, or number, inside the parentheses specifies the layer that you want to use. For this example, we assume
that Solid 1 is the first layer in your composition. To retrieve values from the first layer in the active composition,
type
.layer(1)
at the end of the expression, to get the following:
thisComp.layer(1)
6
Again, look at the expression elements reference to see that
layer(index)
returns a Layer object. Look at “
General attributes and methods (expression reference)
” on page 669, and find the element you want to use. For
example, if you want to get the values of the Position property for the layer, type
.position
at the end of the
expression to get the following:
thisComp.layer(1).position
7
Layer General attributes and methods (expression reference)
” on page 669, you can see that the
position
attribute returns a property. Look up “
Property attributes and methods (expression reference)
” on page 677 and
notice that you can add a time factor to the expression. To add a specific time, such as current time plus 2 seconds,
type
.valueAtTime(time+2)
at the end of the expression to get the following: