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 Mati Toffel on August 31, 2021 at 1:43 pm

    I’m trying to make a timer count up with the expression “time.toFixed(1)”, and I linked it to a Checkbox Control Effect, so that when the checkbox is On, the timer runs, and when it’s Off, the timer freezes at that frame.
    I wanna make it as automated as possible, so I could just put On/Off keyframes and the timer is animated according to the keyframes.
    I tried this expression:

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

    But I don’t know what expression I should use in the else {} statement.
    I don’t wanna use a Slider Control, because the video i’m making requires that the timer has to go exactly at the actual time, not faster/slower. And it’s so hard to get that on point with the slider.

    Any recommendations? I would really apreciate it

    Dan Ebberts
    replied 5 years ago
    2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    August 31, 2021 at 3:21 pm

    Try this:

    p = thisComp.layer("Control 1").effect("Control")("Checkbox");

    t = p.value ? time : 0;

    if (p.numKeys > 0){

    n = p.nearestKey(time).index;

    if (p.key(n).time > time) n--;

    if (n > 0){

    t = p.key(1).value ? p.key(1).time : 0;

    t += p.value ? time - p.key(n).time : 0;

    for (i = 2; i <= n; i++){

    t += p.key(i-1).value ? p.key(i).time - p.key(i-1).time : 0;

    }

    }

    }

    t.toFixed(1)

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