ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Countdown Timer: millisecond goes into minus numbers

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Zac Pickin
Countdown Timer: millisecond goes into minus numbers
on Feb 28, 2019 at 2:49:05 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&lt;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 &lt; clockStartTime) {
addZero(minutes) + ":" + addZero(seconds) + ":" + addZero(milliseconds);
} else {"00:00:00"};


Return to posts index

Oleg Pirogov
Re: Countdown Timer: millisecond goes into minus numbers
on Feb 28, 2019 at 10:24:28 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]