beautypg.com

Adobe After Effects User Manual

Page 680

background image

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")

Reading this expression from left to right, you progress from the higher-level, containing object down to the specific property:

The global object used refers to the current composition: thisComp.

A specific layer object within that composition is referred to by its name: layer("Layer B").

A specific effect object within that layer is referred to by its name: effect("Gaussian Blur").

A specific effect property within that effect is referred to by its name: ("Blurriness").

For the nth component of a multidimensional property, like the y component of an effect control point, append [n] at the end, like this:

thisComp.layer("Layer B").effect("Advanced Lightning")("Origin")[1]

The default object for an expression is the property on which the expression is written, followed by the layer containing the expression; therefore,
you do not need to specify the property. For example, a wiggle expression written on the Position property of a layer can be either of the following:

wiggle(5, 10)
position.wiggle(5, 10)

You do need to include the layer and property when retrieving them from outside the layer and property on which the expression is written. For
example, an expression written on the Opacity property of Layer B, linking it to the Rotation property of Layer A would look like this expression:

thisComp.layer("Layer A").rotation

To see more examples of how this works, use the pick whip to link one layer property to another, and look at the expressions it creates.

Jeff Almasol provides a script on his

redefinery website

with which you can determine how to refer to any property in expressions.

Arrays and multidimensional properties

An Array is a type of object that stores an ordered set of numbers. An Array is represented as a list of numbers separated by commas and
surrounded by brackets, as in this example:

676

This manual is related to the following products: