User Guide

CHAPTER 10
318
Creating Expressions
To construct a simple expression:
1 Start with two layers.
2 Select the Position property for the first layer in the composition and choose Animation
> Add Expression. The following expression appears by default:
position
3 Type the following directly over the word “position:”
this_comp
4 The element “this_comp is a global attribute whose value is a Comp object repre-
senting the current composition.
5 To determine what can follow “this_comp in your expression, look up the return value
for “this_comp under “Global attributes and methods” on page 325.
6 Note that “this_comp returns a Comp. Next, look at the “Comp attributes and
methods” on page 329 to see what you can use with a Comp. One option is layer(index)”.
The index, or number, inside the parentheses specifies the layer that you want to use. To
retrieve values from the second layer in the active composition, type the following:
this_comp.layer(2)
7 Again, look at the expression language guide to determine that “layer(index)” returns a
Layer. Look at “Layer attributes and methods” on page 330, and find the element you want
to use. For example, if you want to access the Position property values for the layer, type
the following:
this_comp.layer(2).position
8 From “Layer attributes and methods on page 330, determine that the position
attribute returns a Property. Look up “Property attributes and methods” on page 335 and
notice that you can add a time factor to the expression. To add a specific time, such as
current time minus 2 seconds, type the following:
this_comp.layer(2).position.value_at_time(time-2)
9 From “Property attributes and methods” on page 335, notice that the time factor
“value_at_time(time)” returns a Number. When an element returns a Number, Array, or
Boolean (such as true or false), you cannot add other attributes or methods to the
expression (if you want, however, you can add operators such as +, -, *, or /).
10 Click outside of the expression to activate it.
UG.book Page 318 Wednesday, February 21, 2001 12:05 PM