Tips & Tricks for looping keyframes with expressions in After Effects

Adobe Employee ,
Jun 24, 2020 Jun 24, 2020

Copy link to clipboard

Copied

Instead of copy-pasting your keyframes through the whole composition, use expressions to loop your animations!

 

 

Here's the walkthrough. After you've keyframed one loop of your animation...

  • Alt + click (PC) or Option + click (MAC) the stopwatch next to the parameter you want to loop – scale, position, rotation, etc.
  • Delete the code that displays in the expressions editor
  • Replace it with one of the following expressions
    • loopIn("cycle") will repeat your animation before the keyframes in your timeline. The animation will end at the last keyframe.
    • loopOut("cycle") will repeat your animation after the keyframes in your timeline. The animation will end with your composition.
    • loopOut("continue") will take the last two keyframes of your animation, and continue that stroke indefinitely.
    • loopOut("pingpong") will carry your animation forwards and backward through the keyframed positions.
    • loopOut("offset") will bring the entire animation along. The animation will repeat itself starting from the last keyframed point.

 

Note: the default loop effect is set to "cycle" and can be left out of the expression for convenience. 

  • loopIn() and loopOut() will produce the same animation as loopIn("cycle") or loopOut("cycle")

 

Hope this helps!

TOPICS
FAQ , How to

Views

23.6K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 06, 2020 Jul 06, 2020

Copy link to clipboard

Copied

Little extra tip:

If you own iExpressions, you can create these loops without writing any expression code yourself.

The Loop iExpression offers all the features of the loopIn and loopOut expression plus some very handy extra features like looping both in and out simultaneously and to auto-smooth loops.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

Nice addition, Mathias! Thanks for the bonus. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 12, 2020 Jul 12, 2020

Copy link to clipboard

Copied

That's cool. Here is the way that i usually do, you can check on it:

sportnews24h_0-1594617265798.jpeg

You mographers probably use a simple loop expression, “loopOut()”. And I think once you’ve thought that you wanted to loop only specific keyframes like an image above. It’s easy to do with expression!

[Expression]

1
loopOut("cycle", 2);

 

[Quick Explanation]

1
loopOut(type="cycle", numKeyframes=0);

loopOut() has 2 arguments, loop type and number of keyframes. The number of keyframes is keyframe segments to loop. If you use “loopOut(“cycle”, 1)”, it loops the segment bounded by the last keyframe and second to last keyframe.

I learn this from beatgram. It's while useful.

 

Best regards,

ThaiSon

 

 

Thethao24h

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Nov 29, 2021 Nov 29, 2021

Copy link to clipboard

Copied

Excelente aporte!
saludos

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 17, 2022 Feb 17, 2022

Copy link to clipboard

Copied

Thanks for sharing. It was quite informative.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2022 Mar 17, 2022

Copy link to clipboard

Copied

Thanks for sharing

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 04, 2022 Apr 04, 2022

Copy link to clipboard

Copied

Thank you for the info! My question would be, what if you turned the animation into a mogrt to use in premiere? If you added protected regions to the Ae comp and extend the layer on the Premiere timeline, would the infinite loop animation continue to play or just end at the original Ae comp timecode? 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 21, 2022 Jun 21, 2022

Copy link to clipboard

Copied

LATEST

I've actually made a really simple panel you can use to automatically add loop expressions (including to shape layers).  I do a lot of looping and I've found it a real time-saver!
You can download it (free) from:

https://frankmansfield.co.uk/stuff/loop.php

Give me a shout with any questions  🙂

Cheers
-f

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines