LIBRARY: Tutorials Reviews Interviews Editorials Features Business Authors RSS Feed

After Effects Expressions Simplified

After Effects Tutorial from The Creative COW Magazine

Creative COW Magazine presents After Effects Expressions Simplified

Andrew KramerAndrew Kramer
Murrieta California, USA

©2007 Andrew Kramer and All rights reserved.

Article Focus:

In this After Effects tutorial from The Creative COW Magazine, see through the confusion of After Effects Expressions with just a few simple steps.

Using expressions, anyone can link filters and transformations, as well as many other parameters, to drive powerful new effects and streamline job processes. The operative word here is `anyone' - and in this case, I do mean just about anyone. Don't let the idea of expressions scare you.

Admittedly, After Effects expressions can be complicated but for the everyday After Effects user, powerful expressions are well within reach and they are easier than you might think. A simple example of using expressions lays in the pickwhip function.

The pick-whip allows users to easily create expressions that can accomplish techniques which would take a lot more work using After Effects' other methods.

Suppose I'm doing some motion graphics and I want 20 pictures to all be tinted a certain color. Easy enough, I can tint one and then copy and paste the effect to each of the 19 other photos. But if you're like me, you are constantly making changes and don't want to keep copy and pasting all of these changes so that your images look consistent. To solve this problem, we're going to use expressions to link parameters together without any actual scripting, just by using the pickwhip.


Here's how to control the tint color for multiple layers at once:

1. Add the tint effect to your first layer or your `control' layer.

2. Change the `Map Black To' (see Figure 1 below) color to Red.

3. Then on your second layer, add another tint effect.

4. Now Alt-Click (CMD-Click on Mac) on the Stopwatch of the `Map Black To' color and the timeline window will expand.

5. A text box will appear and while everything is still selected, mouse over to the left where you see the expression functions.

6. The one that looks like a swirl is called the Pick Whip. Click and drag it to `Map Black To' color parameter on the control layer and let go. You may have to expand the control layer properties.

7. Now copy the 2nd layers tint effect and paste it to any additional layers that need to be linked. The code is essentially hard coded so you do not need to repeat the steps.

8. Then change the control layers tint color and watch as all the pictures change to the same color.

Expressions Example
Figure 1

Expressions like this are great for keeping everything in sync and making multiple changes at once. Using the pick whip is a great way to link similar effects. But what about linking different effects together?

Let's study the original example, linking the blur amount to the opacity to create a smooth fade-in or out; essentially we want to change the opacity of a layer and drive the blur amount at the same time.

1. Add the fast blur effect to your layer

2. Alt-click the stopwatch for "blurriness"

3. Type: linear(transform.opacity,0,100,50,0)

Now a month ago if I had seen this expression I would have thrown my hands up and just made extra keyframes. But let me explain the last line in a way that has helped me to understand expressions.


Inside the parenthesis are five values separated by commas. The first is the specific property; After Effects has to know what is to be considered - in this case, the transform.opacity. Remember you can pick-whip any parameter to automatically type a parameter's property name.

The next two values indicate the parameter range to be considered, in this case the opacity amount from 0-100.

The last two are what values are to be executed - or in this case the blur amount. In other words the opacity of 0-100 generates the values for the blur of 50-0. Why 50-0 and not 0-50?

When the opacity is at 100 percent, we want the blurriness to be 0 and when the layer is completely transparent we want it to be blurred by 50. So if I wanted more blur I might use this expression...


...increasing the max blur to 200 or dropping it to as little as 20.


`Linear' is a common method in which to remap these values across time so that the change is gradual but direct. Using this method you are able to link non-uniform values like the opacity with a layer's rotation, where rotation values span from 0-360 degrees compared to opacity which is 0-100.

If you were to use an expression on the rotation it might look something like this:


Using this expression, as the layer fades out, it will also rotate 360 degrees.


I remember back in high school when I had to figure out what `y' equaled if y=x+4 and x=6. Well, for those of you that have been out of school for a while, y=10. If I remember correctly, they referred to these as "variables." One way to think of a variable is a value that is "to-be-determined." In other words, a variable is a dynamic value or number based on specified or notyet- specified values. Once all the non-specified values are determined, the variables value is generated and integrated into the expression or simply executed. I may not have paid much attention in math class but some of it has come back to me.

Using variables with expressions allows After Effect to create incredibly more effects.


An example of using variables is found when creating a realistic camera shake. This effect, which we'll start and later modify with a variable, is best implemented through expressions. Possibly the most famous simple expression is:


When applied to the position of a layer, this expression will create random values - or in this case, random movement. In this example, wiggle is the function and A is the number of changes per second, with B representing the distance of change. wiggle(5,10) when applied to the position of layer would cause the position to change direction 5 times per second and move 10 pixels at a time.

The Wiggle function is a great way to add random movement to layers, creating more realistic animations - but what if I wanted to generate an earthquake that comes and goes gradually? Currently, this expression uses exact values that don't change but using a variable that is linked to a slider control we can keyframe this earthquake effect over time.

If you've tried to use an effect from the expression controls category, you may have noticed that nothing happens; you may have thought something was wrong and deleted it. In order to work properly, these expression controls must be linked to actual operators like position or opacity.

So let's get started, we want to create a camera shake on the position of a layer...

1. Alt-click on the stopwatch to set layers position

2. Type: wiggle(5,10)

Notice the layer shakes a bit. Let's continue:

3. Add the effect "Slider Control" from the expression control category in the effects list

4. Rename the effect in the effects control to "shakeAmount"

5. Return to the position expression and change the number 10 to shakeAmount

It should now read: wiggle(5, shakeAmount)

AE Expressions
Figure 2


Now we need to define the variable so After Effects knows what is being referenced by the word "shakeAmount".

6. above the line with the wiggle script [or below] type: shakeAmount =

7. Then with the blinking type cursor positioned after the `=' drag the pickwhip to the shakeAmount slider in the effects controls. [or timeline]

8. The property info should print something like this:
shakeAmount = effect("shakeAmount")("Slider")

9. Then add a semicolon to the end to define it as a variable.
shakeAmount = effect("shakeAmount")("Slider");
wiggle(5, shakeAmount)

Now if you change the value in the effects control to 25, you'll see the clip shake and the position value should show up in red (instead of blue), indicating an expression is driving the value. So if you haven't guessed, the shakeAmount variable is getting the value from the shakeAmount slider - and the shakeAmount variable is defining the wiggle amount.

Now you can easily keyframe the amount of shake using the slider control. You may also change the number 5 to create rapid or smoother movement. But when you're tired of going back into the expression editor to make changes to the frequency you may want to set up another variable.

Follow the steps above with a new Slider control named `frequency' and add it to the current expression to create this:

shakeAmount = effect("shakeAmount")("Slider");
frequency = effect("frequency")("Slider");
wiggle(frequency, shakeAmount)

Now you can keyframe or adjust both expression sliders dynamically without editing code. But wait, there's more! You now have it shaking, but couldn't it also rotate?

Simply copy everything in the `position' expression and paste it into the rotation property - everything is already linked to the sliders, so we'll use the current variables to drive a rotation and the position.

Now you may notice that the rotation expression is creating relatively large values - turning a thing 15 or 20 degrees is jarring - but if you lower the shake amount to soften the rotation, the layer's position no longer shakes enough. If the shakeAmount slider is set to 20 we're probably getting rotation changes around 20 so we need to make this value lower but we don't want to make new sliders. Here is an easy solution; take the current expression and divide it by 10.

Copy expression from the position:

shakeAmount = effect("shakeAmount")("Slider");
frequency = effect("frequency")("Slider")

Paste to rotation and simply divide by ten by adding this:


shakeAmount = effect("shakeAmount")("Slider");
frequency = effect("frequency")("Slider")

Now when a value of 20 is created by the wiggle expression it is then divided by 10 and now this new value is executed so instead of rotating 20 degrees it only rotates 2.

Imagine linking multiple layers to one control layer so that you could globally make adjustments to entire compositions with variables and various expression controllers. Once you get beyond the basic fundamental uses of expressions, start thinking about creative ways to drive unique effects with math equations and random movement.

I've created some expression based effects that help to simplify creating light sabers as well as generating three dimensional falloff and even an accurate frame rate converter for PAL to NTSC conversions as well as 29.97FPS to 24FPS or vise versa.

For me it was Dan Ebberts on the Creative Cow forums that opened my eyes. I've always been a visual person and was told that you're either a creative person or a technical person. With Dan's help the concept of expressions is no more complicated than the things I already do. And while I'll never be an expert code writer I have found creative ways to use expressions to streamline unique effects. I've also learned one more thing, writing code is creativity squared.

If you need help with expressions, check out the Creative COW's After Effects Expressions forum, dedicated to those wanting to dig deeper into the power of After Effects expressions.

Andrew KramerAndrew Kramer is a visual effects artist and filmmaker. He is one of the leaders you'll find in Creative COW's popular After Effects forum, as well as our Photoshop forum. As a Creative Cow contributing editor, his free tutorials have been downloaded hundreds of thousands of times and in them he has demonstrated popular effects like creating the Ipod Nano Light Streaks and Simulated 3D reflections in AE.

Andrew is also the creator of Serious Effects & Compositing, Creative Cow's best selling video training DVD for After Effects, one of the Creative Cow Master Series training DVDs available at:

Find more great Creative COW Magazine articles by signing up for the complimentary Creative COW Magazine.

Find Value of property and access in other layer
by Sumit Badsara
How can we bring value of some other property from other layer and save it in a varibale.
For eg.
I Created audio to keyframe layer, than added expression of lineat to convert bass to effect, than i want that layer's value?

val = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

i wanted something like this..
Re: After Effects Expressions Simplified
by Annie Chou
Thank you Andrew!!! I still watch your tutorials nowadays~
Re: After Effects Expressions Simplified
by Chris Warren
Awesome as usual Andrew! I attribute 90% of my After Effects knowledge to you

Re: After Effects Expressions Simplified
by Stef Prein
Thanks, Andrew! I didn't know I could use the same expressions on rotation controls, as I used on position controls. Great!

Stef Prein
director/motion designer at StudioFets.
Utrecht, The Netherlands

Related Articles / Tutorials:
Adobe After Effects Expressions
Adobe After Effects Expressions 101

Adobe After Effects Expressions 101

Expressions in Adobe After Effects open up a world of possibilities for your visual effects! Expressions can be daunting when you first get into them, though, as you have to essentially write 'code' - and code can be scary. Join After Effects guru Tobias Gleissenberger of Surfaced Studio for the first in a series covering expressions, from the very basics - all the way through to programming the Matrix!

Tobias Gleissenberger
Adobe After Effects Expressions
In The Loop - A Killer Expression

In The Loop - A Killer Expression
  Play Video
A detailed explanation and demonstration of the uses of the loop expression in After Effects. Examining the loopOut(), loopIn(), loopInDuration(), loopOutDuration() commands and their "ping pong", "cycle" and "continue" modes.

Tutorial, Video Tutorial
Matthew Tompkins
Adobe After Effects Expressions
EQ Animation using AE Expressions

EQ Animation using AE Expressions
  Play Video
In this video tutorial Matt Tompkins gives some great tips on how to create and animate a rack of Graphic Equalizer bars using solely expressions in Adobe After Effects.

Tutorial, Video Tutorial
Matthew Tompkins
Adobe After Effects Expressions
Jack of All Trades, Master of Expressions

Jack of All Trades, Master of Expressions
  Play Video
In this video tutorial, Creative Cow contributing editor Eran Stern demonstrates how to create a jumpy and squishy animation using the power of expressions.

Tutorial, Video Tutorial
Eran Stern
Adobe After Effects Expressions
AE Quick Tips #4: Copy Expression Only

AE Quick Tips #4: Copy Expression Only
  Play Video
In this video tutorial, CreativeCow leader Aharon Rabinowitz shows you a menu item for speeding up the process of copying expressions to other layers, without typing or altering the current values.

Tutorial, Video Tutorial
Aharon Rabinowitz
Adobe After Effects Expressions
Animating Text Reflections with ExpressionsAnimating Text Reflections with Expressions

In this tutorial from Creative COW Contributing Editor Trent Armstrong, you'll see how to use Expressions to animate reflected light across text. You can get great results using only ingredients included free with AE, including track mattes and the AE Camera.

Trent Armstrong
Adobe After Effects Expressions
Swinging A Realistic ChainSwinging A Realistic Chain

Creative COW member Trent Armstrong shows you expression features that apply all the way from After Effects 5 to today. He combines his experience as an average expressions user with tips and shortcuts for many core features that every AE user will be able to start using today.

Trent Armstrong
Adobe After Effects Expressions
Building and Animating a CG SnakeBuilding and Animating a CG Snake
  Play Video
In this video tutorial from you will learn how to create a dynamic animation based on a chain rig. You will also learn how to animate one layer using keyframes, expressions, or both, and make other layers follow the leading layer. The rest of the tutorial is about texturing and making the final look.

Tutorial, Video Tutorial
Jerzy Drozda Jr
Adobe After Effects Expressions
Using Expressions to Create a Volume MeterUsing Expressions to Create a Volume Meter
  Play Video
In this video tutorial from you will learn how a smart way of creating dynamic a sound reactive Volume Meter using Expressions in After Effects.

Tutorial, Video Tutorial
Jerzy Drozda Jr
Adobe After Effects Expressions
A better Grid using expressions

A better Grid using expressions

This tutorial from Mylenium will show you some basic principles when using expressions in After Effects. These include using the pick whip and some simple things you need to think of when referencing elements and converting numerical values.

© 2020 All Rights Reserved