What are expressions?
In After Effects you can change a layers properties (such as position or opacity) by typing in or dragging the values, adding keyframes to change them over time. This process of changing and animating properties forms the basis of working in After Effects.
- What if rather than setting a property manually, you need it to always be the same as another one?
- Or you need it to decide what value to have based on something else?
This is where expressions come in, as an alternate way of setting the value of properties.
They enable you to combine values together and have a property choose what it's value is.
Expressions are lines of computer code that After Effects runs every frame to generate the value of a property.
How to add an expression
You can add an expression to a property in After Effects by:
Holding alt while clicking on the properties stop watch (the icon next to it's name)
Using the 'Add Expression' shortcut alt + shift + = with the property selected
Clicking Add Expression in the Animation menu while the property is selected
These will add a new expression with some placeholder code to the property.
This placeholder code references the before expression value, which is the value of the property as if there was no expression applied. This means you can continue to modify and animate the property as if there was no expression.
Setting the value
For example, let's replace our position property expression with a new value.
You'll learn more about the
 syntax in future topics.
Now the postion of the layer will always be at
960, 540 even if we change or animate the property, as it is overidden by the expression.
[960 + 50, 540 + 100];