Using the loopOut() Expression in After Effects

Free Online After Effects Tutorial

In this tutorial, we're going to show you how to use the loopOut() function in Adobe After Effects. LoopOut() is one of many things you can do with the Expressions language that is part of Adobe After Effects.

Getting the Project Files

Download the project files

After the download has finished, be sure to unzip the file if it hasn’t been done for you.

Link to project files: 

https://www.nobledesktop.com/downloads/blog/Tutorial-50-LoopOut-Animation.zip

Project Overview

Setting Up The Anchor Points

  1. Double click on the mantle clock layer to go inside the Precomp.
  2. Select the hour hand and hit Y for the Pan Behind tool. Drag the Anchor Point to the base of the hour hand.
  3. Repeat the previous step with the minute hand and the pendulum.

Animating and Adding Expressions

  1. Select the pendulum layer and hit R for Rotation.
  2. Click on the stopwatch next to Rotation to set a keyframe, and change the Rotation angle to 30 degrees.
  3. Move the Playhead in about a second or so, to 0;00;01;00.
  4. Change Rotation to -30 degrees. 
  5. Select both keyframes, right click on either selected keyframe, and navigate to Keyframe Assistant > Easy Ease.
  6. Alt-click on the blue Rotation stopwatch to add an Expression. Type in LoopOut(“pingpong”) to have the pendulum swing back and forth in a loop.
  7. Select the minute hand. Hit R for Rotation.
  8. With the Playhead at the origin, click on the stopwatch next to Rotation to set a keyframe.
  9. Move the Playhead in about a second to 0;00;01;00.
  10. Change the first value in the minute hand’s rotation to 1, so it makes one full revolution around the clock.
  11. Alt-click on the blue Rotation stopwatch to add an Expression. Type in LoopOut(“”), which is the default Loop expression. 
  12. Move the Playhead back to the origin, and select the hour hand. Hit R for Rotation and click the stopwatch next to Rotation to set a keyframe.
  13. Move the Playhead over to 0;00;01;12 about.
  14. Change the hour hand’s degree of Rotation to 30 degrees.
  15. Alt-click on the blue Rotation stopwatch to add an Expression. Type in LoopOut(“offset”), so that whenever the hour hand loops, it adds its initial value of 30 degrees to its Rotation.

Video Transcription

Hello, this is Tziporah Zions from Noble Desktop, and in this tutorial, I'm going to show you how to create this loop expression animation in Adobe after effects. We're going to be using a few really simple expressions bits of code in Adobe after effects to make this looping animations that repeat like forever effectively.

So you can see this is what it looks like when it's completed. So expressions are lines of code. Like I said, they're used to automate some animations within the program. So like, there's no need to do the manually.

So they're a lot easier and less scary than they sound, and they help a ton of speeding up your workflow. So while sometimes it can be long and complicated, we'll be using small ones today. Very often we'll want to loop animations or social media posts or more complex projects and need repetitive animations within them.

This tutorial will try to get those done really quickly and very easily. The only external file we're going to be using is this clock graphic, and that should be preloaded into the project file when you open it up.

It was set up prior before in Adobe Illustrator with separate layers so it could be animated in after effects. It's stored in the assets folder, in the project folder if you need to rethink it for whatever reason. And you can find the entire project file in the video description below.

So let's get started. All right, so we're going to be getting into this mantle clock precomp by double clicking on it. And that should take us to the screen. And we're going to be paying attention also to the hour hand, the minute hand and the pendulum.

The first thing that we're going to be doing is hit Y on the keyboard to bring up the anchor point tool. This is the reference point for the object for after effects, for when it's when animating. So I'm going to start from the pendulum and we're going to want to grab it and drag it over the base of

each object. That's kind of where it's going to be swinging from the hour hand as well, all the way to the bottom minute hand that's dragging it down. I'm going to hit V on my keyboard to go back to the selection tool, and now I'm going to be animating the pendulum, so on the pendulum, hit R for rotation.

You know, it should start at around, let's put this at 30 degrees. There you go. Put down a key, you know, hit the stopwatch. Just start that first keyframe and let's have a repeat about, you know, a minute and a half, it'll have the other side.

So we'll put a negative 30 because it's swinging the other way and highlight both key frames right click, go to Keyframe Assitant, Easy Ease. It's going to make this look more organic and smooth. Now we're going to put in here, first expression.

So alt click the little stopwatch, the active stopwatch, next to rotation, and we're going to start putting in a little teeny teeny bit of code over here. And the program actually has them pre-loaded into it. So as soon as you start typing loop, it'll give you a couple of loop options.

We're going to be using three different ones in this project. So we're going to first, we're going to choose Loop Out. I'll explain the difference between these guy. Loop out and in the parentheses, we're going to do quotation marks and then we're going to be choosing ping pong.

The reason for this is because and then also deselect. So it'll activate. It'll refresh an updated animation. So let's preview this animation. Swings one way, swings the other way. So you can see that it'll repeat this animation.

We only have two key frames, but this thing is going to keep going and going and going, you know, till whenever we decide to make it stop. And you'll see that it goes from one side to the other and then it'll go back the opposite way.

It ping pongs. Now the difference between loop out and loop in as you saw those looping options is that loop in will loop the animation, but it'll it'll stop before the first keyframe looping into the animation. But loop out will, you know, loop beyond the last keyframe, right?

So you see that, you know, our key frames end over here, but it'll keep moving after that. Safe. There's also, you can alter loop out by adding in a modifier, N-U-M keyframes, numkeyframes and that'll specify like how many key frames you want looping here, but we're just using the basic out of the box.

Oh, looping expressions. All right. So let's head over to the minute hand over here. And we're also going to rotate that thing. So we want to hit the stopwatch to start our keyframes. Let's put this. I wanted to make a full revolution for two seconds in.

So for rotation in that first little box over here, I'm going to put in one. I'm not going to easy ease these things because I don't, I want it to kind of behave very mechanically. It is a clock and we are going to loop this.

So again, click on the active stopwatch, start writing Loop now for this loop out. We're actually just going to leave this one blank. Alternatively, we can type in cycle, but cycle is, you know, instead of ping pong where we type in cycle.

But cycle is actually the default loop. So check what happens when we preview this. So you can see that the, you know, that hand keeps going round and round and round and round. And you know, that's what the basic about expression does or loopOut cycle.

It just keeps the previous value going round, and that's a pretty simple. Nothing else. So now we are going to animate the our hand. So like before select the hour hand rotation, I have my Playhead at the beginning.

I'm going to hit this stopwatch and I'm actually going to have this go a little longer, double the time of the minute hand. And I'm going to be changing it incrementally by 30 degrees. So it's in second box and the rotation values. And now.

For this one, we're going to be using slightly different looping command looping expression. So click on the active stopwatch, loop out the one we're going to be using. So in quotation marks is offset. So what offset does is that it takes that initial change in value and it keeps adding it to itself.

So I'll show you what I mean when I preview this. All right, so you can see as the hour hand moves along, it's moving by increments of 30, meaning that from here to here on the timeline it'll move 30 degrees and then, you know, and that same amount of time, it's nearly three seconds.

So nearly six seconds it moved 60 degrees, you know, so it added 30 degrees to itself. And yeah, so that's what Offset does. Now I will also want to show you that the cool thing about loops is that they'll also adjust to when you move your keyframes around.

So I'm actually going to grab all my key frames and I am going to change their time. I'm going to make it move really fast and then let's see how that looks. So let's play. And you can see that it's still looping, even when they moved a lot faster, when I set that back to how they were

before. This also works, if I would extend these, you know, these key frames or loop out, you know, beyond those key frames. You can also expand and shorten the ProComp and the layers as well. The loops still behave.

So that's loop out. It's easy to see how this can help in a lot of other after effects projects. You can automate everything from text to objects. With this expression, you can animate the wheels on a car going on forever, a hopping bug, some text scaling in small and big, any anything that needs to continue in a loop.

So it's not just rotation, it's position and scale as well. The offset expression is extra useful for objects with unusual motion paths too, if it's moving in a squiggle. It'll it'll repeat that as well. So there's a lot of flexibility with that.

That's all for this tutorial. I hope you've enjoyed learning how to make this loopOut effect in Adobe after effects. This has been Tziporah Zions for Noble Desktop.

How to Learn After Effects

Master After Effects with hands-on training. After Effects is the industry-standard application for motion graphics, animation, and visual effects.

Yelp Facebook LinkedIn YouTube Twitter Instagram