How to Use the loopOut Expression in After Effects
The loopOut expression in Adobe After Effects is a
powerful tool designed to automate repetitive animations without the
need to manually copy and paste keyframes. This article explains what
the loopOut expression is, how it works, and how to use its
various parameters to create seamless cycles, ping-pong effects, and
continuous motion along your composition's timeline.
What is loopOut?
In Adobe After Effects, loopOut() is a built-in
expression written in JavaScript that tells a property to repeat its
keyframed animation continuously after reaching the final keyframe.
Instead of duplicating keyframes hundreds of times—which clutters the
timeline and makes future edits tedious—applying loopOut()
allows you to alter a single set of keyframes while the expression
automatically propagates those changes across the entire duration of the
layer.
How to Apply loopOut
To add the loopOut expression to any keyframed
property:
- Create at least two keyframes for a property (such as Position, Scale, or Rotation).
- Hold Alt (Windows) or Option (macOS) and click the stopwatch icon next to the property name.
- In the expression field that appears, delete any default text and
type:
loopOut() - Click anywhere outside the text box to activate the expression.
By default, typing loopOut() with empty parentheses
executes the standard cycle loop for all keyframes on that
property.
Loop Types
The behavior of the repeat cycle can be altered by inserting specific
loop types inside quotation marks within the parentheses:
loopOut("type").
1. Cycle:
loopOut("cycle")
This is the default setting. Once the playhead passes the final keyframe, the animation instantly jumps back to the first keyframe and plays forward again, repeating this sequence endlessly. It is best used for looping backgrounds, rotating gears, or repetitive mechanical movements.
2. Pingpong:
loopOut("pingpong")
The pingpong property plays the keyframes forward from
start to end, reverses them backward from end to start, and repeats this
back-and-forth cycle indefinitely. This type is ideal for pendulums,
blinking eyes, or pulsing elements.
3. Offset:
loopOut("offset")
Instead of resetting to the beginning, offset repeats
the animation relative to the value of the last keyframe. Each new cycle
begins where the previous cycle ended, carrying over the accumulated
change. This is ideal for walking characters that move across the screen
or objects progressing continuously in one direction.
4. Continue:
loopOut("continue")
Unlike the other types, continue does not repeat
keyframes. Instead, it measures the velocity of the property at the
final keyframe and continues moving in that direction at that exact
speed indefinitely.
Limiting Keyframe Ranges
You can also specify how many keyframes should be included in the
loop by adding a number as a second argument:
loopOut("type", numKeyframes).
- If you use
0, it includes all keyframes. - If you set
numKeyframesto1, After Effects only loops the segment between the last two keyframes. - A setting of
2loops the segment spanning the last three keyframes.
For example, loopOut("cycle", 1) creates an intro
animation using the initial keyframes, but only repeats the final
keyframed motion for the remainder of the layer.