Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Q: Looping offset with decreasing/increasing value

  • Q: Looping offset with decreasing/increasing value

  • Ben Jackson

    March 4, 2020 at 3:44 am

    Hello! Don’t know if there is a simple fix for this: I want to create a loop using the “offset” tool, but instead of taking the specific numeric change from keyframe A to B, I want it to use the ratio of change between those keyframes. Specifically, I want it to divide by three every time it repeats the keyframes: going from 960 to 320, 320 to 106.6, and so on. I’ve no idea how to tell the computer to do this, it doesn’t seem like a common need to begin with. If anyone’s got any ideas, I’d love to know. Thanks!

  • Tomas Bumbulevičius

    March 4, 2020 at 8:47 am

    Hey Ben, could you please specify actual use case scenario? Meaning, do you still plan to define ‘first loop’ with keyframes, and then begin division from there? Or, as longs as it do what is suppose to – it doesn’t matter?

    Find out more:
    After Effects Tutorials: motion design, expressions, scripting.
    Boxer – Dynamic Text Boxes Template with a Live Preview

  • Ben Jackson

    March 4, 2020 at 10:16 am

    Hi Tomas, thanks for the reply!

    Correct, I’d like to set the initial keyframes and have a loop that essentially extrapolates from there. In this case, each time the keyframes go from A to B, I want to make B = A/3, rather than the same numerical difference of A – B every time.

    I’d like this to happen because I am creating a swipe-by style animation of photos. Every 40 frames, a photo “swipes off” to the left, yanking in a new photo from the right at a faster speed (crossing over the old photo fading off). Rather than animate every photo, I’ve set each photo’s X value to 3 times that of the preceding one, daisy-chaining them all to the first photo. However, this means I’m still manually keyframing each instance of X-axis movement on that first photo. Because each photo’s position is compounded on the previous one’s, the keyframes have to offset the change in X to 1/3 of the initial X value every loop.

    Hopefully this gives a clearer picture of what I’m looking for; I’d be happy to post a screenshot of what’s going on in my timeline too, if that would help.

  • Dan Ebberts

    March 4, 2020 at 5:11 pm

    See if this is close:

    if (numKeys > 1){
    if (time < key(2).time){
    r = key(1).value/key(2).value;
    d = key(2).time - key(1).time;
    t = (time - key(2).time)%d;
    n = Math.floor((time - key(2).time)/d);
    valueAtTime(key(1).time + t)/Math.pow(r,n+1);


Viewing 1 - 4 of 4 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy