Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions looping but with a pause feature?

  • looping but with a pause feature?

    Posted by Blake Goulette on July 26, 2024 at 2:09 pm

    Hi there.

    I have a precomp that I have looped — just using loopOut() — but at some points, I want to be able to “pause” the loop where it is. Maybe loopOut() isn’t really what I want here, but I’m not sure how to get this to work. I tried adding time remapping and a hold keyframe, but the loopOut() just ignores that entirely.

    I thought about trying to get the duration of the animation (between 2 keyframes) and somehow use a valueAtTime expression tied to…something else, I don’t even know what at this point!

    There’s gotta be a way to accomplish this — and it’s probably pretty simple and I’m just overlooking it. Would appreciate any advice or ideas. Thank you!

    Brie Clayton replied 1 year, 9 months ago 3 Members · 7 Replies
  • 7 Replies
  • Blake Goulette

    July 26, 2024 at 2:21 pm

    Not exactly what I wanted (or thought I could get away with!), but looping the animation in the precomp (and extending its timeline longer than necessary), I can use hold keyframes with Time Remapping to more or less accompish my goal. It’s not as elegant or customizable as I hoped, but it seems to work for now. Still open to any better options, thanks!

  • Dan Ebberts

    July 26, 2024 at 9:54 pm

    How were you thinking of controlling the hold time?

  • Blake Goulette

    July 26, 2024 at 10:00 pm

    Hi Dan. I had hoped I could add, say, a checkbox control: if checked, let the loop progress; if unchecked, keep the loop where it was when the checkbox value was changed (on a particular keyframe). But that threw errors: I didn’t know what to use for an else condition, and the loopOut() itself didn’t work. Something like this:

    allowLooping = thisComp.layer(“N FX”).effect(“Checkbox Control”).value;
    if (allowLooping)
    {
    loopOut();
    }
    else
    {
    // ?!
    }

    But, obviously, that’s broken. Thanks again for asking!

  • Dan Ebberts

    July 26, 2024 at 10:35 pm

    Try this:

    p = thisComp.layer("N FX").effect("Checkbox Control")("Checkbox");
    t = 0;
    if (p.numKeys > 0){
    n = p.nearestKey(time).index;
    if (p.key(n).time > time) n--;
    if (n > 0){
    for (i = 1; i <= n; i++){
    if (p.key(i).value == true){
    if (i < n){
    t += p.key(i+1).time - p.key(i).time;
    }else{
    t += time - p.key(i).time;
    }
    }
    }
    }
    }
    if (numKeys > 1){
    if (t > key(numKeys).time){
    t = key(1).time + (t - key(numKeys).time)%(key(numKeys).time - key(1).time);
    }
    }
    valueAtTime(t)
  • Blake Goulette

    July 29, 2024 at 2:37 pm

    Dan, thank you so much! That seems to do the trick! I appreciate your help!

    While I’m here, what do you suggest I read/study to get a better understanding of just what exactly all that code is doing? Or how to know what elements/properties to manipulate to achieve what you shared above? I can hamfist my way though some stuff, but other times I have no real idea of where to start. Thanks again!

  • Dan Ebberts

    July 29, 2024 at 9:11 pm

    Other than a few basic JavaScript manipulations, I think you’ll find everything I used there in the Expressions Language Reference section of AE’s help, specifically in the Properties Attributes and Methods and the Key Attributes and Methods sections.

  • Brie Clayton

    July 30, 2024 at 12:56 am

    Thanks for solving this one, Dan!

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