Back to Blog

Amazing Expressions in After Effects

By Caleb Ward
After Effects

In this tutorial we'll cover a few fantastic expressions in After Effects that you may have never used.

Today we’re going to be talking expressions, but more specifically we will be taking a look at some lesser-used expressions in After Effects that can be incredibly useful in a Motion Graphic workflow. Some of these After Effects expressions you may have heard of before, but I promise you’ll learn something new. And if you don’t learn something new you can have every penny that you paid to watch this tutorial back.
So if you’re ready to learn something new here’s the tutorial.
You can also download the project files used in this tutorial by hitting the download button below.

Download the After Effects Expression Project File

Download Project File

5 Unique Expressions in After Effects

Here is the list of After Effects expressions used in this tutorial.

1. Loop Offset

Expression: loopOut(“offset”); or loopIn(“Offset”);
After Effects Offset.gif
You may already be familiar with the loop expression in After Effects, but you may not be familiar with the more specific Offset Loop expression. In short, the Loop Offset expression continues keyframe values beyond the last keyframe. If you want more explanation go check out the loop expression tutorial from the team here at School of Motion.
After Effects Offset Offset Chart.gif
One of the very unique and interesting ways in which you can use the loop expression is through creating speed sliders on the fly. For example, if you wanted a shape to move across your composition at a steady rate you could add the loop expression to two keyframes and adjust the keyframe distance to perfect the movement.
It’s a fantastic way to quickly adjust repetitive movements.

2. Index

Expression: index;
After Effects Offset Index.gif
The index expression isn’t rocket science, but it is nevertheless an incredibly powerful tool in After Effects. Essentially the index expression returns a value based on the layers position in the timeline. For example, a the 4th layer in a timeline will return a value of 4.
After Effects Offset index chart.gif
The true power of the index expression comes through using it as a way to offset values. Whether you’re linking it up to a random seed, or using it as a way to move offset the position of a shape layer there is a lot of potential ways to utilize this expression.

3. Linear

Expression: linear(inputvalue,InputValueLow,InputValueHigh,OutputLow,OutputHigh);
Example: linear(thisComp.layer("AudioLayer").effect("Both Channels")("Slider"),0,20,700,200);
After Effects Offset Linear.gif
The linear expression is magic. Essentially the linear expression gives you the ability to input a string of values (numbers) and output another string of values based on a new proportion. Confused?
That’s what I thought. Let’s talk about an example…
Let’s say you created an After Effects template and you wanted to give users the ability to control the size of a shape layer with a slider that could be adjusted from a value of 0 to 100, but you want the size of your shape to only scale between the value of 5 and 20.
After Effects Offset Linear chart.gif
Obviously you couldn’t just pick whip your shape scale to that slider because that would give anyone using your template the ability to adjust the scale of the layer from 0 to 100. Instead, you could use the linear expression to set the proportional output values so that 0 is mapped to 5 and 100 is mapped to 20. After Effects will do the rest of the math.

4. Clamp

Expression: clamp(input,minimum,maximum)
Example: clamp(thisComp.layer("Layer 1").effect("Slider Control")("Slider"),852,1700);
After Effects Offset Clamp.gif
The clamp expression can be thought of as a way to create a ceiling for the potential values of layer. Using the clamp expression you can tell any property that it cannot go below a minimum value and it can’t go above a maximum value.
After Effects Offset Clamp chart.gif
This is super useful when creating projects that will be used as templates by non-designers.

5. ValueAtTime

Expression: valueAtTime(value);
Example: thisComp.layer(index-1).content("Polystar 1").content("Polystar Path 1").outerRadius.valueAtTime(time-.5);
After Effects Offset valueAtTime.gif
The valueAtTime expression returns the value of another layer at a specific time. Think of it as pick-whiping to the value of another layer at a very specific moment in the timeline. This can of course be very useful in a lot of different ways, but the way in which I’ve found this to be super useful is through using it as a way to offset animations.
After Effects Offset valueAtTime chart.gif
To use the expression all you have to do is call the layer property that you are trying to reference and add .valueAtTime(x) where x is the specific time in which you would like the value to be taken from. If you use the ‘time’ expression in place of a specific number it will basically mirror the values from the property that the value is taken from.
Hopefully you’ve learned something new. If you haven’t watched our After Effects Expressions 101 tutorial go check it out. With a bit of practice you’ll be better at expressions than Vladimir Putin is at making balloon animals.
Vladamir Balloon Animals.gif
View More From

Motion Graphic Tips and Tricks

After Effects
5 Free After Effects Tools

In this After Effects tutorial we'll take a look at a few of our favorite free tools in After Effects.

After Effects
Tutorial: Make a Better Glow in After Effects

Stop using the glow effect! This tutorial will show you how to make a better glow in After Effects.

See the whole Collection