Skip to main content
iang24856705
Participant
January 18, 2018
Question

How can I successfully use the Loop expression?

  • January 18, 2018
  • 1 reply
  • 2507 views

I'm still fairly new to After Effects and I'm working on a project that requires a lot of animations to loop, but using the Loop expression is completely racking my brain at the moment because I'm consistently encountering issues with it. Would any of you please help me figure out what I'm doing so horrendously wrong?

Just to illustrate the problem I'm having with a simple example, I've made a basic animation consisting of only three frames, displaying the numbers 1 to 3. I want to create a loop so that the numbers will play in the following sequence: 1 > 2 > 3 > 1 > 2 > 3...ad infinitum.

I've created a comp with this animation called "numbers".

Here's the animation where the numbers go from 1 to 3 rapidly, with each number lasting just one frame. This is how I want the loop to look.

I created a new comp and called it "loop", and placed the above comp into it. This is where I want to create the loop.

I've enabled Time Remapping and stretched out the clip to fill the timespan of the comp.

I added the Expression and typed in loopOut();

I know this part is finicky because it makes the last frame disappear in the first segment of the loop. I understand the trick is to go to the penultimate frame in the Time Remapped clip, and create a new keyframe in Time Remapping there. Then I'm supposed to delete the last keyframe. So I went ahead and did that.

And this is where I invariably encounter problems. For example, here's the animation that results. In this case, it seems to start with playing the first two frames, and then it just holds on the first frame for the rest of the "loop". The third frame is nowhere to be seen.

Since I've carefully laid out the steps in my process, can anyone figure out what I've done wrong here?

Thanks a lot for the help! I really need to overcome this hurdle with the Loop expression because it's the only real issue keeping me from completing my project.

This topic has been closed for replies.

1 reply

Community Expert
January 18, 2018

if you use the K key to go to the last time remapping keyframe you will see that it has been placed after the end of the video. The first thing you need to do is move back to the start of the last frame where the 3 is visible and set a keyframe there, then delete the last one.

Careful examination of the timeline and actually checking each keyframe would have shown you the problem instantly. Time remapping works this way on purpose so you get every frame and the time values for each frame are correct. 

Mike_Abbott
Legend
January 18, 2018

when you've set up time remap and have your two keyframes - one at the start and one at the end,

you need to:

1. add one time remap keyframe at the current value one frame before the last keyframe.

2. COPY the first time remap keyframe and PASTE IT over the LAST time remap keyframe.

and add loopOut().

iang24856705
Participant
January 18, 2018

Hi Mike, thanks for your reply also!

I've never come across your method before -- I've always read that I need to make a keyframe on the penultimate frame of the Time Remapping, and then delete the last keyframe, as Gerard above also mentions. I tried your method and it worked with my numbers loop, so I finally managed to get that one looping properly. Thanks!

Unfortunately when I applied your method to an animation I'm working on, the loop just holds on the first frame. It seems like the results can vary every time I try to make a loop -- either it holds on a frame, or it loops without the last frame, or sometimes even two layers show up in the same frame creating an overlap. At the moment it really feels like if I actually get a loop working properly it's a complete fluke!

Thanks again for all the help.