Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to pause/stop a Time Expression ?

  • How to pause/stop a Time Expression ?

    Posted by Mike Jones on July 11, 2014 at 11:01 am

    Hello,

    I am making a Soccer TV broadcast template.

    I have this expression below that counts the time from 00:00.

    Now how can I make it stop/pause when it reaches 45:00 (The end of first half).

    Thanks.

    countspeed = 1;
    clockStart = 0;

    function times(n){
    if (n < 10) return "0" + n else return "" + n
    }

    clockTime = clockStart +countspeed*(time - inPoint);

    if (clockTime < 0){
    minus = "-";
    clockTime = -clockTime;
    }else{
    minus = "";
    }

    t = Math.floor(clockTime);
    h = Math.floor(t/3600);
    min = Math.floor((t%3600)/60);
    sec = Math.floor(t%60);
    ms = clockTime.toFixed(3).substr(-3);
    minus + times(h) + ":" + times(min) + ":" + times(sec) + "." + ms

    Dan Ebberts replied 12 years ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    July 11, 2014 at 4:14 pm

    This change would make it stop at 45:00:

    clockTime = Math.min(clockStart +countspeed*(time – inPoint),45*60);

    Dan

  • Mike Jones

    July 11, 2014 at 7:08 pm

    Thanks it worked.

    Now if I want it to start at 45:00 (for the second half) and stop at 90:00

    I tried to edit these two expression lines:

    clockStart = 2700; //(2700 so it can start at 45:00)

    clockTime = Math.min(clockStart +countspeed*(time – inPoint),90*60);

    But when I try to change the second expression to 90*60, the time returns to 00:00 when it reaches 59:59.

    How can I make it work ?

  • Dan Ebberts

    July 11, 2014 at 8:28 pm

    Something like this maybe:


    countspeed = 1;
    clockStart = 0;
    periodDur = 45*60;
    halfTimeDur = 15*60;

    function times(n){
    if (n < 10) return "0" + n else return "" + n
    }

    if (time > (inPoint + periodDur + halfTimeDur)){
    t = time - (inPoint + periodDur + halfTimeDur);
    clockTime = Math.min(periodDur + countspeed*t,90*60);
    }else{
    t = time - inPoint;
    clockTime = Math.min(clockStart + countspeed*t,45*60);
    }
    if (clockTime < 0){
    minus = "-";
    clockTime = -clockTime;
    }else{
    minus = "";
    }
    t = Math.floor(clockTime);
    h = Math.floor(t/3600);
    min = Math.floor((t%3600)/60);
    sec = Math.floor(t%60);
    ms = clockTime.toFixed(3).substr(-3);
    minus + times(h) + ":" + times(min) + ":" + times(sec) + "." + ms

    It’s not going to work quite right though if you change countspeed or clockStart.

    Dan

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