Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Timer time.toFixed(1) linked to a checkbox control effect.

  • Timer time.toFixed(1) linked to a checkbox control effect.

    Posted by Honey Blaas on August 31, 2021 at 7:42 pm

    I’m trying to make a timer count up with the expression “time.toFixed(1)“, and I want it to link it to a checkbox control effect, so when the checkbox is on, the timer runs, but when the checkbox is off, the timer freezes at that frame. I want it to be as automated as possible, so i would only have to keyframe the On/Off of the Checkbox Control Effect.

    I tried this expression:

    if(thisComp.layer("Null 1").effect("Checkbox Control")("Checkbox")>0){time.toFixed(1)} else {}

    But I don’t know what expression use in the “else” statement. If there’s any expression that would make the timer stop at the time i put the checkbox in “Off”, i would happier than ever.

    I’d really apreciate it if you helped me with it. Thanks

    Fabrice Leconte replied 4 years, 11 months ago 2 Members · 1 Reply
  • 1 Reply
  • Fabrice Leconte

    September 4, 2021 at 9:17 pm

    Hello, try this:

    myNull = thisComp.layer('Null 1').effect('Checkbox Control')(1);

    freeze = 0;

    for (i = 1; i <= myNull.numKeys; i++) {

    if (i != myNull.numKeys && myNull.key(i) == 0 && time >= myNull.key(i).time) {

    freeze += Math.min(myNull.key(Math.min(i + 1, myNull.numKeys)).time, time) - myNull.key(i).time

    } else if (i == myNull.numKeys && myNull.key(i) == 0 && time > myNull.key(i).time) {

    freeze += time - myNull.key(i).time

    }

    }

    (time - freeze).toFixed(1);

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