Adobe After Effects Basics – Expressions

In today's tutorial we are going to look at a feature of Adobe After Effects that I've used in most of my tutorials without ever going into too much detail: expressions.

Instead of keyframing a property in After Effects you can write a little piece of code, an expression, that controls the value of the property for you. This expression can be very simple or very complex and you can introduce some intelligent logic into your composition and create some amazing visual effects.

Diving into Expressions

I am going to approach this tutorial a little bit differently. I will throw you into the deep end first and then pull you back out so we can look at all of the details that we missed the first time around. Ready?

To get started with this tutorial, create a new composition. Add a new text layer anywhere into your scene and change the text to 'Slider Value: '. Then create a new Null Object and call it 'CONTROL'. Search for and apply the 'Slider' effect to the null object. Finally, add keyframes to the Slider effect to animate the value of the slider to increase from 0 to 100 over the course of your composition. Your composition should now look something like this:

Expand the text layer until you can see the Source Text property and ALT-click onto the little stopwatch icon. Yes, this will add an expression, but I will cover that in more detail soon. For now just follow along and in the little text editor that appears in your timeline window on the right side type

"My slider value: " +

and then, with the active cursor still in the text editor, drag the pick whip icon on the left side onto the Slider value on the CONTROL null object and let go.

This will insert even more code into your little expression, but we will look at that later. Add '.value.toString()' to the end of your expression to convert the slider value to a string and then click outside of the text editor. The text in your composition should now be animated and display the value of the slider when you scrub through your composition.

This setup will make it a lot easier for you to see how expressions affect the slider value. So now let's come back from the deep end and look at the very basics of expressions in Adobe After Effects!


User avatar
6 Years Ago
May 21, 2014 @ 11:11 am
Please Ineed This Program )))))
User avatar
Manuel Gonzalez
5 Years Ago
May 2, 2015 @ 1:01 pm
Hi there!!! i have a question,

i followed the steps on your webpage, but the expression on the source text isnt working for me so i cant really start with the tutorial :/

after i pick whip the source text with the slider effect i got this error

invalid numeric result (divide by zero )

this is how my expression looks:

"slider value: " +

thisComp.layer("CONTROL").effect("Slider Control")("Slider")

what could it be my mistake?

THanks a lot!! you really do a great job!!!

Show less
User avatar
Surfaced Studio@ Manuel Gonzalez
5 Years Ago
May 11, 2015 @ 10:07 am
You need to append '.value.toString()' to the end of the expression. I was actually missing it from the description of the tutorial (fixed). It's in the video at around 10:30
User avatar
3 Years Ago
August 26, 2017 @ 7:23 am
Hi. I think there is is some mistake into hue expression. There is "for (i = 1; i < thisComp.numLayers; i++)" but shuold be "for (i = 1; i <= thisComp.numLayers; i++)"
"<=" instead "<"
User avatar
2 Years Ago
June 29, 2018 @ 8:04 am
Hi Michal, thank you for the correction. I've fixed up the code in the post accordingly
User avatar
1 Year Ago
November 24, 2018 @ 9:33 am
Hi. Thanks! Any idea how I could adapt this to the 'scale' or 'opacity' property?
User avatar
1 Year Ago
February 13, 2019 @ 10:14 pm
You can apply expressions in the same way to any property. Scale is a vector with [INVALID TEMPLATE: {type}] values and opacity is just a single number from 0 to 100

Please leave a comment

Click here to enter some text...


Get in touch via social media


Tobias Avatar
I am passionate about providing high quality VFX & Film Making Edutainment online. Check out my training courses on Udemy
© 2020 Surfaced Studio