How to Use Expressions in After Effects

Perhaps the most powerful tool in your After Effects arsenal, expressions enable you to achieve your effects by producing values for parameters than can then be linked to other actions. The primary feature of expressions is that they reduce the need for hundreds of manually set keyframes for animation and for any motion animated they make the job a much quicker process.

1. Assigning an expression to a parameter

To show the basic use of expressions, I have created a new composition and placed 2 solid layers on it. The bottom one is black, the second one is blue.


If I now set the opacity of the blue layer to zero at the start of the timeline, you can just see the black layer underneath.


If we wanted to set the opacity of the blue layer to gradually increase, we could, in this instance, use keyframes easily between two points to achieve it, however we can add an expression here to illustrate how they work.

Selecting the chosen parameter and then either going through Animation>Add Expression or the shortcut of holding Alt (or Option for Mac) whilst clicking on the stopwatch opens up a text box. I’m using opacity, and in the text box I type time*7.


What this does is use the timeframe value in seconds, multiplies it by 7 and sets the opacity for the blue layer at that. So from no it rises up until it reaches its maximum of 100. Yes, this is a very simple demonstration but this principle is how expressions work, and it is far easier to grasp the concept from these kinds of examples.


There are some things to note about a parameter once you have placed an expression on it. Firstly, you will notice the value is displayed in red. This indicates it is being controlled by an expression and cannot be changed manually.

You will also note there are some extra buttons to the side of the expression label. The first one is an = sign, this is the button to turn off the expression temporarily without deleting it, as you test or work through a sequence for instance. The second is a graph button that enables the values of the expression to be plotted within the graph view.


As you would expect from the formula used, the graph shows the opacity rising with time for the blue layer.

The third button is the pick whip button that enables us to create simple expressions very easily. Dragging the pick whip from one parameter to another creates a live link between the two that sets the value of the current parameter from the value of the other. For a simple link that is a very quick way of achieving it.

A good example of this is if I open an expression for rotation, and drag its pick whip onto our opacity parameter that is still set to increase with time.

I shrank the blue layer a little so you can see the effect in the frame here.


What happens when you play this now, is that not only does the opacity increase as before, the layer also rotates with it.


As you can see, the ability to connect different parameters can enable quite complex relationships to be achieved very quickly and easily.

Dragging the pick whip in this way can create the same kinds of relationships across different layers, further expanding the possibilities.

It is worth noting that what the pick whip does in essence is to auto create the expressions for a given connection for you, you can do the same manually if you are well versed in expressions, and it is important to remember you can edit the text created by the pick whip to modify effects if you wish to.

The final button is the language editor, which allows you to select the phrase understood by the After Effects from the various options rather than typing them from memory. Selecting one places it into the expression text bar.

2. Vectors

There is some terminology you need to get to grips with when working with expressions, one of the major ones are vectors and arrays. To show this I have added a new text layer containing the word Expression on top of our existing project. If we use the whip to connect the position and opacity parameters, you will see the value in the expression is

temp = transform.opacity;

[temp, temp]


Notice that it creates two values, this is because although opacity has a single value, position requires two (3 if it were a 3D layer of course) values to function, the x and y values.

The expressions that contain two or more values are called vectors or arrays. They are very common in After Effects, everything from anchor points, positions to scale include more than one value.

Please note, although most documentation seems to use the words interchangeably, a vector comprises only numbers, whilst an array includes words or other text objects as well.

By including a number in brackets after each value (such as anchor point[0], anchor point[1] and so on, always start with 0 for the first one) in an array, you can refer to them directly and extract just that value, this is known as indexing. So, if you wanted the y value of a position, you would use Position [1] (the second value) and this would return the y axis value at that time point.

3. Expanding on Expressions

As we can see, things can quickly become quite complex with expressions, although they do offer a deep control system for complicated animations and so forth, so it is perhaps to be expected.

However, there is some good news, many people make extensive use of the abilities of expressions without every fully getting to grips with the language. This is because there is a plethora of expression libraries on the internet where you can find and copy expressions for almost anything you can imagine, all for free.

Now some will say this is a shortcut and doesn’t help long term, but I do disagree with this, and here is why. Because you can see the expression as well as what it is doing, using other peoples expressions is a fantastic way to understand how things are achieved, you can modify them and learn how they do what they do, it is a great way to not only get some great effects very quickly, but to learn how to recreate similar effects yourself from scratch.

Some people may simply use expression libraries and never look any further, but I think that for those that use them as a tool for learning, they are a fantastic resource and the perfect way to expand your expression knowledge.

They're downloading



One-stop solution lets you manage your entire mobile lifestyle convenient.

Data Recovery

Data Recovery

(Recover lost files)

Recover files in 550+ formats from your computer storage quickly, safely and completely.

Home > Resource > Video > How to Use Expressions in After Effects
All Topics