User Guide
Using Help | Contents | Index Back 252
Adobe After Effects Help Creating Expressions
Using Help | Contents | Index Back 252
• Position[0] is the x coordinate of position
• Position[1] is the y coordinate of position
• Position[2] is the z coordinate of position
The After Effects-specific elements Layer, Effect, and Mask use an indexing process that
starts from 1. For example, the first layer in the Timeline window is as follows:
layer(1)
Generally, it’s best to use the name of a layer, effect, or a mask instead of a number to avoid
confusion and errors if the layer, effect, or mask is moved. When you use a name, always
enclose it in straight quotes. For example, the first expression below is easier to under-
stand than the second expression, and it will still work if you change the order of effects:
effect("Colorama").param("Get Phase From")
effect(1).param(5)
Accessing specific values in a vector or array
You can create an expression that references just one value within the array of a 2D or 3D
property. By default, the first value is used, unless you specify otherwise. For example, if
you drag the pick whip from layer 1’s Rotation property to layer 2’s Scale property, the
following expression appears:
this_comp.layer(2).scale[0]
By default, the above expression uses the first value of the Scale property, which is width.
If you prefer to use the height value instead, drag the pick whip directly to the second
value instead of the property name, or change the expression as follows:
this_comp.layer(2).scale[1]
Conversely, if you drag the pick whip from layer 2’s Scale property to layer 1’s Rotation
property, After Effects automatically duplicates the expression so that two values are
available for the scale. The following expression appears:
[this_comp.layer(1).rotation, this_comp.layer(1).rotation]
To use a different value as one of the value parameters instead of doubling the one
rotation value, remove the duplicate expression and insert a value. For example, to use the
rotation value for the scale’s height and 10 for the width, use the following expression:
[this_comp.layer(1).rotation, 10]
Using the expression language menu
The expression language menu contains all the After Effects–specific language elements
that you can use in an expression. This menu is helpful for determining valid elements and
their correct syntax; use it as a reference for available elements.
Select any object, attribute, or method, and After Effects automatically inserts it in the
expression field at the location of the cursor. Then, edit and add to it as needed. For
example, if you want to begin an expression with the comp as the object, select
“this_comp” from the Global menu:
this_comp
To continue the expression, add a period (.) to the end and then choose an attribute from
the Comp menu, such as “layer”: