5 Shopping Cart
Your cart has been updated

After Effects Quick Tip: Creating Variables

Caleb Ward

Learn how variables can keep your expressions organized in this After Effects quick tip tutorial.

When using expressions in After Effects one of the most important concepts to master is creating variables. Variables are a way to keep your expressions clean and organized. They also happen to be extremely easy to create. In the following quick tip tutorial we will take a look at what exactly variables can do and how to create them in After Effects.

What Are Variables?

In After Effects a variable can be thought of as a container that holds a value. Normally these values are numbers with data that can be used to manipulate number based effects and transform options to your layer, but sometimes they can hold information like layer names, text blocks, and color values.

Typically variables are used to save the time of going in and writing out the entire expression over and over again. They also are a great way to keep your expressions organized and understandable. Variables can be found by looking for the “=” in an expression.

How Do I Make Them?

1. Choose a variable name

Try to choose the best name possible with the shortest amount of letters. If you must use more than one word it’s best advised to use ‘camel case’ with the first word being lowercase and the second being uppercase. So if you wanted to name your variable “My Variable” you would name it “myVariable”.

Screen Shot 2014-11-17 at 10.38.22 AM

2. Add an equal sign

Screen Shot 2014-11-17 at 10.38.42 AM

3. Add the line of expression that you are trying to condense followed by a semi-colon.

You can type it out or even use the pick-whip to link your variable to another layer or effect in your project.

Screen Shot 2014-11-17 at 10.39.10 AM

Why Should I Use Them?

With variables it’s all about organization. Sure you could get by without variables, but if you had a long expression it may become really confusing really quickly. For example, if we were trying to connect a layers opacity to a slider in another composition, your expression would look something like this:

comp(“Controller”).layer(“Control Layer”).effect(“Slider Control”)(“Slider”)

Now we want to add the opacity value of another layer named “Second Layer” to the current layer:

(comp(“Controller”).layer(“Control Layer”).effect(“Slider Control”)(“Slider”)+ thisComp.layer(“Second Layer”).transform.opacity);

And let’s divide both the numbers by 10:

(((comp(“Controller”).layer(“Control Layer”).effect(“Slider Control”)(“Slider”)+ thisComp.layer(“Second Layer”).transform.opacity))/10)

Confused yet? By adding more math and parameters you will quickly find your expressions getting convoluted, but by using variables you can make your expressions much easier to read. So let’s take a look at the same example using a variables. First lets make a variable for the opacity being linked to the slider control and name it “sldr”.

sldr = comp(“Controller”).layer(“Control Layer”).effect(“Slider Control”)(“Slider”);

Now let’s create a variable for the “Second Layer” opacity called “scnd”:

scnd = thisComp.layer(“Second Layer”).transform.opacity;

Now let’s add the two variables together:


and divide by 10


So altogether our final expression looks like this

sldr = comp(“Controller”).layer(“Control Layer”).effect(“Slider Control”)(“Slider”);
scnd = thisComp.layer(“Second Layer”).transform.opacity;


instead of this:

(((comp(“Controller”).layer(“Control Layer”).effect(“Slider Control”)(“Slider”)+ thisComp.layer(“Second Layer”).transform.opacity))/10)

As you can see if you’re working with a lot different parameters it can be much more efficient to use variables to keep things organized.

How do you use variables in your projects? Share in the comments below.

Read More:

After Effects Expression Basics – Adobe
Arrays and Variables – AEExpressions
AE Expressions Simplified – Creative Cow

Get 200+ Video Transitions
Add flair and style to your next cut with these 200 video transitions. Designed for Premiere Pro and FCPX.