Introduction to Adobe After Effects Expressions for Beginners
In Today’s blog we are going to discuss Expressions in Adobe After Effects.
If you're new to video editing and special effects, you might want to start with Adobe Video Production Basics, where we dive into the differences between Premiere Pro and After Effects and explain when to use each program.
Now back to Expressions. What are they and how can they make my life easier?
Expressions are small snippets of JavaScript that are used to create and control animations in a more dynamic way.
Whoa JavaScript – I didn’t sign-up for that!
Before you get too stressed out, know that learning a bit of basic JavaScript is literally going to save you thousands of hours in post-production work!
Here are the key benefits of using Expressions:
- Expressions can be used to automate many repetitive tasks in After Effects.
- Expressions give users the ability to control animations with much greater precision.
- Expressions give you the ability to link the different properties of an animation together. So as one property changes, other properties can change at the same time.
- Lastly, Expressions give the end-user much more flexibility when it comes to editing animations and avoid the laborious task of having to alter numerous keyframes.
The choice is simple: learn a bit of JavaScript and become a super-efficient power user or keep manually editing keyframes and waste thousands of hours on repetitive tasks.
How to Implement Expressions in Adobe After Effects
Before you can use Expression in After Effects, you will need to learn how to add them to different properties in your compositions.
Here is a simple step-by-step instruction.
- Firstly, either open or start a new project in After Effects.
- Next select the property you wish to animate, for example the opacity of a layer, click the stopwatch icon while holding down the ALT key in Windows or Option Key on a Mac to enable Expressions.
- A text box will appear, and this is where you will end the JavaScript-based expression.
- Lastly, you can preview the animation using to RAM Preview to see how the expression affects the property over time.
Next, we are going to look at a few useful expressions for beginners.
Examples of Useful Expressions for Beginners
Example 1: Looping an Animation
A common task in After Effects is creating a loop from keyframed movements. Instead of copying and pasting keyframes, use an expression to loop any set of keyframes seamlessly.
How to Implement: Say you have an object moving from left to right across the screen with two keyframes. Click on the position property, hold Alt or Option and click the stopwatch, then paste the above expression. This expression will make the motion continue indefinitely.
Example 2: Finite Animation with Timing
In this example, we are going to create a simple animation where a layer’s opacity changes over the duration of the timeline.
We will start with the layer’s opacity dropping from 100% to 0% over 2 seconds, in other words it will change from 100% visible over to 0% visible over 2 seconds.
It will remain hidden for 4 seconds, before fading back in over 2 more seconds.
This expression will requires the use of JavaScript conditional statements and the linear() function that will be applied to the opacity property.
Here's a step-by-step explanation of how you can implement this expression:
- Open your project and select the layer you want to animate.
- Apply an Expression to the Opacity Property by Alt-click (Windows) or Option-click (Mac) on the stopwatch icon next to the Opacity property in the layer's property panel to enable expressions.
- Write the Expression
Here's the expression you can use:
- Lastly, adjust the Expression as Needed
You can adjust the fadeInTime, fadeOutTime, and fadeOutDuration variables to change the timing of your fade in and fade out effects to suit your specific needs.
Explanation of the Expression:
During the first 2 seconds (fadeInTime), the expression calculates a linear interpolation from 0% to 100% opacity.
After the fade-in completes and until 4 seconds (fadeOutTime), the opacity remains at 100%.
From 4 seconds onward, it starts another linear interpolation to fade out the opacity from 100% to 0% over the next 2 seconds (fadeOutDuration).
After the total duration, which is the sum of fadeOutTime and fadeOutDuration, the opacity remains at 0%.
Adding an Easy, Fun Animation: Auto-Rotate to Follow Motion
Here’s a simple expression that makes an object automatically rotate to face the direction it is moving, which can be quite useful for animations involving vehicles, animals, or any moving objects.
Example 3: Auto-Rotate Along Path
How to Implement: Apply this expression to the rotation property of a layer that is moving along a path. This will automatically adjust the layer’s rotation so that it appears to be facing the direction it is traveling.
Final Takeaways
So hopefully you can now see the benefits of using expressions and they will assist in creating really precise animations.
If coding feels intimidating, you can use online libraries like AE Reference Expressions, where you can copy and paste pre-written code directly into your project.
These resources will help you get up to speed quickly with Expressions. Start with basic expressions, like the ones provided, before exploring more advanced scripts.
If you would like to learn more about Expressions and other After Effects topics, please join one of our live online After Effects classes or if you are based in Los Angeles – consider one of our in-person After Class offered in Downtown LA.