What Are Loop Expressions and How Do You Use Them?

Loop expressions in After Effects can make your animations look professional. Here’s how.

In this article, we’re going to talk about Loop Expressions in After Effects and how you can easily start using them, regardless of your skills as an animator or motion graphic artist. This approach to animating your titles, logos, characters, or shapes is an amazingly effective way of making your work stand out and look like it was made by a professional animator.

Here on the Videvo Blog, we’ve actually covered loop expressions before and how they can elevate your work for the different avenues of publication that a client might request. Check out that article here

What Is an Expression?

An After Effects expression is a piece of code that you apply to a property of a layer or an effect to create an animation or complex actions and movement between different elements in your comp. Expressions in After Effects are written in JavaScript, specifically the ExtendScript scripting language. Expressions are used to automate animations and behaviors. Instead of manually keyframing every change, like we all learned how to do once we started using After Effects, you can write an expression to control a property based on certain conditions, mathematical operations, or even input from other layers. So you’re essentially telling the object/scene how you want it to animate or move.

To apply an expression in After Effects, just hit “Alt-click” (Option-click on Mac) on the stopwatch icon next to the property you want to animate. This opens the expression editor, where you’ll input your code. We’ll talk about which codes do what here in a minute. You don’t need to know how to write code, so don’t fret! You can use pre-built expressions or write custom code (if you want) based on whatever kind of effect you’re trying to make. For our example here, we’ll be discussing expressions that “loop” — or “Loop Expressions.” These make your animation repeat over and over again, creating a cycle. Let’s discuss. 

What Is a Loop Expression?

To put it plainly, “Loop” expressions are used to create animations that repeat or cycle over time. These expressions allow you to create seamless and continuous motion without having to manually keyframe every frame of the animation. There are several loop expressions you can use, depending on your specific needs. 

Loop expression properties are the parameters and options that you can use when using loop expressions in After Effects. These properties allow you to customize the behavior of the loop, controlling different aspects of that loop such as the type of loop, the number of repetitions, and more. When you apply a loop expression, you can include these properties to “customize” the loop to do whatever you need it to. So let’s go over some examples of this practice and discuss some common loop expression properties. 

Different Loop Expressions to Try Out

The “type” property specifies the type of loop. The most common types are “cycle” and “pingpong.” Yes, you read that correctly — “pingpong!”

  • loopOut(type = “cycle”): creates a seamless cycle. If your last keyframe has the same values as your first Keyframe, After Effects will create a neverending loop! 
  • loopOut(type = “pingpong”): creates a pingpong effect, playing the animation forward and then backward. This and “cycle” are probably the most common loop expressions you’ve seen in animations.
  • The “num keys” property lets you specify the number of keyframes that the loop should use. For example, loopOut(type = “cycle”, numKeys = 1) would create a loop using only the first keyframe.
  • The “duration” property sets the duration over which the loop occurs. It is often used with the modulus operator (%) to create loops based on a specific time interval – ‘time % duration: repeats the animation every specified duration.
  • The “offset” property allows you to offset the start time of the loop, creating a delay before the loop begins. So it creates a seamless cycle starting from the first keyframe and introduces a 5-frame delay before the loop begins — loopOut(type = “cycle”, numKeys = 0, offset = 5);

Remember, you can also customize any loop expression. So an example of a “customized” loop expression is one with a wiggle expression added, like the tutorial below!

Expressions can seem daunting, but once you start using them, you’ll always want to integrate them into your workflow. I have a Google Doc with all of the expressions I’ve ever used so I can copy and paste them into AE right away. 


Cover Image via Freepik.

Looking for filmmaking tips and tricks? Check out our YouTube channel for tutorials like this . . .

Avatar photo

Logan Baker

Logan Baker is a filmmaker and photographer based in Denver, Colorado. He has a passion for documentaries and landscape photography.

Articles: 28