
08 Jun Looping in & out in After Effects
One of the most useful expressions in Ae is loop, as we can create -and easily control- an animation with few keyframes. Looping allow us to keep going before or after our animation by allowing Ae to do the math for us. There are four different types of loop: cycle, continue, offset and pingpong. Ping pong is self explanatory as well as cycle; offset is a smoother version of cycle and continue calculates the animation between two keyframes and keeps the value going in a linear way.
In order to use these expressions first we need to create a minimum of two keyframes, and then add it to the property. We can then loop the beginning or the end or the animation by using one of the possibilities (cycle, continue, offset or pingpong):
loopIn(type="cycle"); // loops before first keyframe loopOut(type="continue"); // loops after last keyframe
However there is a problem when we try to use them both at the same time as we’ll soon discover we need something else to make them work: a condition. For this we use the if/else statement; something that could be read as: if the playhead has not arrived yet to the position of the first keyframe then do this, and once the playhead has passed the last keyframe then do that. For this we can use the next expression:
if (time < key(1).time) loopIn("continue") else (value); if (time > key(numKeys).time) loopOut("continue");
Which can be read as, if current time of the playhead is less than the time of the first keyframe then loopIn(“continue”) otherwise keep looping. Keep the animation values between the first and last keyframe and once the playhead has passed the last keyframe then loopOut(“continue”).
Take into account that this is not limited to only one loop type as we can even choose one loop type for the input and another for the output.
Notes:
· key(1) gives back the property value on the first keyframe. If we add .time to it we’ll get the time value at that position.
· key(numKeys).time gives back the time value on the last keyframe(which is the result of the sum of all keyframes).
No Comments