MANUAL / SCRIPTING & EXPRESSIONS

Looping and time (expressions)

loopOut(), loopIn(), valueAtTime(), timeToFrames() and framesToTime().

Looping

FunctionWhat it does
loopOut(type, n)After the last keyframe, repeats the animation.
loopIn(type, n)Before the first keyframe, repeats the animation.

type defaults to "cycle". n (optional) loops only the last (loopOut) or first (loopIn) n keyframes; 0 or omitted uses them all. Both can be called bare (on this property) or on another property: thisComp.layer("A").transform.rotation.loopOut().

TypeWhat it does
"cycle"Repeats from the start.
"pingpong"Plays forward, then backward.
"offset"Repeats, adding the change of each loop on top of the last.
"continue"Keeps going at the speed of the last (or first) keyframe.

A property with fewer than two keyframes isn't looped.

Time

FunctionWhat it doesDefaults
timeThe current time in seconds.
valueAtTime(t)This property's keyframed value at t seconds.
prop.valueAtTime(t)Another property's value at t.
timeToFrames(t, fps)Seconds to a whole frame number.t = time, fps = comp frame rate
framesToTime(frames, fps)Frames to seconds.fps = comp frame rate

Examples

loopOut("pingpong")
loopOut("cycle", 2)
valueAtTime(time - 0.25)                 // lag a quarter second
thisComp.layer("Leader").transform.position.valueAtTime(time - index * 0.1)

Notes

valueAtTime and the loops read keyframed values before modifiers, as AE's valueAtTime on the expression's own property does.