Expressions in After Effects are based on the JavaScript programming language.
Let’s take a deep dive into JavaScript components that are specific to After Effects.
An object is an element that can take the form of compositions, footage, layers, and effects.
They are the core of expressions and can be nested and chained together to create complex references.
You can think of objects as containers for other objects or attributes.
After Effects has a built in set of extension objects to provide comp, footage, layer,
and effect objects for you automatically as you create them in the project.
An attribute is a property or a trait of an object that it’s attached to.
These can be global comp attributes like time or frameDuration, layer attributes
for width or height, or even property attributes like speed or value.
In JavaScript, these are called properties, but After Effects uses the term attributes
to avoid confusion with its own effect properties.
Some common example attributes may include value, inPoint, and duration.
When attached to an object, an attribute can access specific data points and return their values.
In most cases, the attribute is the final piece of an object chain.
You can’t chain any additional objects or attributes beyond it.
A method is a special instruction that accepts arguments to run a specific task.
They are distinguishable by a set of parentheses containing arguments.
A method is like a verb, it performs an action on a value.
Some common examples of methods include: wiggle(), valueAtTime(), and linear().
Methods are powerful and allow you to use advanced manipulation on values.
Some methods, like valueAtTime() and sourceRectAtTime()
act similar to an attribute and can be chained to an object.
Other methods, like linear() and hslToRgb() are standalone and only need arguments to work.
An operator is a basic math equation, like addition or multiplication.
An operand is the value you are operating on.
It can be a number, an attribute, a method, a variable,
or multiple attributes wrapped in parentheses.
An operation is a group of operators and operands that make a complete statement.
Some commonly used operators include:
multiplication, division, remainder, addition, subtraction, increment, and decrement.
A few example operations might include value multiplied by time, transform scale minus
a custom array, or value plus 10, wrapped in parentheses, and then divided by 2.
A statement is a logical phrase consisting of operators, values, attributes, methods,
and other instructions to be executed.
Here’s a few examples of common statement structures:
transform scale multiplied by 5
x equals 1, y equals 2, z equals 3, separated with semi colons,
time minus the first layer's in point in the composition, wrapped in parentheses, plus 5.
So how does After Effects know which statement you want to use as the final output?
It all comes down to the order of evaluation.
In almost all cases, After Effects will take the last statement evaluated and output the result.
This is usually the last line of your expression.
In some cases, a conditional statement may be evaluated as the final output,
depending on the conditions.
A variable is a pre-defined statement that you store and retrieve
at different parts of your expression.
They include a unique identifier and the statement you are defining, separated by an equal sign.
It's a great way to keep code clean, and make it easy to understand, and avoid redundancies.
Some different types of variables and their statements may include myVal equals 100,
pos equals a custom array, t equals thisComp duration minus 10.
These variables can be combined, overwritten, incremented, and used in many different ways.
The key to a strong expression is the consistent use of easy-to-understand variables.
We've arrived at the end of Lesson 501: Covering the Basic Components of JavaScript Expressions
If you enjoy this expressions course, consider purchasing the paid content.
It includes in-depth documentation, extra tutorial content, high definition videos,
and all the project files used in the training.
Your purchase will help to create more free courses like this in the future.