Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Countdown Timer: millisecond goes into minus numbers

  • Countdown Timer: millisecond goes into minus numbers

    Posted by Zac Pickin on February 28, 2019 at 2:49 pm

    Having trouble with a countdown timer using a slider control, when the milliseconds go below a certain number the final character goes into minus numbers. I am sure it’s a really simple expression change I just can’t work it out. If anyone could help that would be great,

    If anyone needs anymore information please shout, thanks!

    rateOfSpeed = 1 ;
    rateOfSpeedMilli = 100;
    clockStartTime = thisComp.layer("Timer Duration").effect("Slider Control")("Slider")*60;

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

    clockTimeNumber = Math.floor(clockStartTime - rateOfSpeed*time);
    clockTimeNumberMilli = Math.floor(clockStartTime - rateOfSpeedMilli*time);

    minutes = Math.floor(clockTimeNumber/60);
    seconds = clockTimeNumber%60;
    milliseconds = clockTimeNumberMilli%100;

    if (clockStartTime > 0 && time < clockStartTime) {
    addZero(minutes) + ":" + addZero(seconds) + ":" + addZero(milliseconds);
    } else {"00:00:00"};

    Oleg Pirogov replied 7 years, 4 months ago 2 Members · 1 Reply
  • 1 Reply
  • Oleg Pirogov

    February 28, 2019 at 10:24 pm

    I suppose, this Math.floor(clockStartTime – rateOfSpeedMilli*time) is negative most of the time.
    I suppose, this Math.floor(rateOfSpeedMilli*(clockStartTime – time)) is what you meant it to be.

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