Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Expression to hold animation

  • Expression to hold animation

  • Graham Quince

    October 8, 2022 at 3:12 pm

    I’m trying out something and already have a manual alternative if this doesn’t work.

    I have a layer, with the position animating across the screen. I’m controlling its opacity through another expression and woud like it to freeze in place every time its visible, so that it only moves when the opacity it 0.

    I had used Hold keyframes and replaced these with layer markers, but whenever you alter any part of the animation you have to readjust the markers.

    I feel like I’m close with trying to base it on valueAtTime, something like:

    var pos = value;

    for (var i = 0; i<time; i++) {

    if (transform.opacity.valueAtTime(time-i) == 100) {

    pos = transform.position.valueAtTime(time-i);

    break;

    } else {

    pos = value;

    }

    }

    pos;

    AE just crashed on me, so I’m guessing I introduced an infinite loop, although I can’t spot it.

  • Dan Ebberts

    October 8, 2022 at 4:50 pm

    Something like this, maybe:

    f = fAccum = 0;
    while (f < timeToFrames(time)){
    if (opacity.valueAtTime(framesToTime(f)) > 0) fAccum++;
    f++;
    }
    valueAtTime(framesToTime(fAccum))
  • Graham Quince

    October 8, 2022 at 6:53 pm

    Dan,

    Thank you – as always your understanding of code is astonishing.

    I flipped the IF though, as I only want the layer to travel when invisible

    f = fAccum = 0;

    while (f < timeToFrames(time)){

    if (opacity.valueAtTime(framesToTime(f)) < 1) fAccum++;

    f++;

    }

    valueAtTime(framesToTime(fAccum))

    Thank you again

Viewing 1 - 3 of 3 posts

Log in to reply.

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