User Guide

CHAPTER 10
320
Creating Expressions
Numbers and arrays
Arrays represent multidimensional values in expressions. The value of each property in an
expression is a single number or Boolean value for values such as opacity, or an array for
2D, 3D, or 4D values such as position or “bg_color”. Many properties in After Effects, such
as position, scale, and color, have more than one value parameter and thus are represented
by different dimensions of arrays. For example, position is represented as a 2D or 3D array
because the Position property can have 2 [x, y], or 3 [x, y, z] parameter values. Colors are
represented as 4D arrays, [r, g, b, a]. Values in a color array range from 0 (black) to 1
(white).
Note: The members of an array are always separated by commas. For example, the expression
[10, 20] sets the property’s x value to 10 and y value to 20.
Indexing vectors and arrays
Indexing is a way of retrieving values in vectors and arrays. Vector and array indexing
starts from 0—for example:
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, its 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 understand
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)
UG.book Page 320 Wednesday, February 21, 2001 12:05 PM