I've got a composition with a few layers of precomps. I enabled Time Remapping on each and added this script: loopOut(loop="cycle",numKeyframes=0) Works great. I'd love to be able to limit the number of times the animation loops, though. Is that possible? Thanks much!
Dan's solution is elegant, but I think this one is more useful.
If the first and last frames of the nested comp are identical so you can have an identical loop, and you went to the last Time Remapping keyframe, moved back one frame, set a new TR keyframe, then deleted the last one, so you have a perfect seamless loop try this:
Time remapping works internally on frame numbers. If you convert time to frame numbers, you can multiply the frame number of the Time Remapping keyframe by the number of loops you want. Combine that with an if statement, and you get this.
fr = time / thisComp.frameDuration;
t = key(2).time / thisComp.frameDuration;
nL = 8
if (fr < t * nL)
That expression will loop the animation eight times and then stop. You can also slide the last TR keyframe left or right in the timeline to change the speed of the loop without modifying the expression.