Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Checkbox Control with more complex expression.

  • Checkbox Control with more complex expression.

  • James McCavana

    July 5, 2022 at 12:13 pm

    Hello there,

    I’m trying to enable/disable an expression with the Checkbox Control and can’t get it working. I found a few helpful threads on this forum but I keep getting errors. I think the errors occur due to my mis-handling of the – }else{value}; part of the expression.

     

    Basically, I have this old favourite expression that I’m applying to layers (letters) as they whizz onto screen to form a text super.

     

    // Inertial Bounce (moves settle into place after bouncing around a little)

    n = 0;

    if (numKeys > 0){

    n = nearestKey(time).index;

    if (key(n).time > time){

    n–;

    }

    }

    if (n == 0){

    t = 0;

    }else{

    t = time – key(n).time;

    }

    if (n > 0 && t < 1){

    v = velocityAtTime(key(n).time – thisComp.frameDuration/10);

    amp = .02;

    freq = 3.0;

    decay = 5.0;

    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

    }else{

    value;

    }

     

    But I’d like to disable the expression once the letters have settled so that the keyframed animation I have for when they LEAVE the screen is not affected by the bouncing.

     

    I’ve tried and tried to get it set up correctly, but just can’t do it. Please could I have some help in setting this up?

     

    Many thanks,

     

    James.

     

     

  • Dan Ebberts

    July 5, 2022 at 3:17 pm

    <div>This assumes that you’re using 2 keyframes to get your letters on screen, and gives the overshoot 2 seconds to settle out. If your conditions are different, you’ll need to adjust the second line:</div>

    val = value;
    if ((numKeys >= 2 && (time < key(2).time + 2)) || numKeys > 0){
    n = nearestKey(time).index;
    if (key(n).time > time) n--;
    t = n > 0 ? time - key(n).time : 0;
    if (n > 0 && t < 1){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    amp = .02;
    freq = 3.0;
    decay = 5.0;
    val = value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }
    }
    val

  • James McCavana

    July 5, 2022 at 4:22 pm

    Hi Dan,

    Thank you. I don’t understand what you mean. I’m just looking to toggle off the expression using the Checkbox Control. The expression is working just fine, I just can’t figure out how to place the bounce expression within the Checkbox Control expression.

    Does that make sense?

    Thanks.

  • Dan Ebberts

    July 5, 2022 at 5:01 pm

    Ah, OK. I think this should work:

    cb = effect("Checkbox Control")("Checkbox").value;
    if (cb){
    n = 0;
    if (numKeys > 0){
    n = nearestKey(time).index;
    if (key(n).time > time){
    n--;
    }
    }
    if (n == 0){
    t = 0;
    }else{
    t = time - key(n).time;
    }
    if (n > 0 && t < 1){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    amp = .02;
    freq = 3.0;
    decay = 5.0;
    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{
    value;
    }
    }else{
    value;
    }
  • James McCavana

    July 5, 2022 at 5:19 pm

    Hi again Dan, that’s perfect! Works exactly how I need it, thank you so much.

    I just wanted to say… I’ve been using your expressions for many many years now, and you’re quite a legend! Thank you.

Viewing 1 - 5 of 5 posts

Log in to reply.

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