Activity › Forums › Adobe After Effects Expressions › 5 Minute Countdown
-
Dan Ebberts
June 16, 2015 at 7:56 pmThis gives a two-second delay:
rate = -1;
clockStart = 300;
delay = 2;function padZero(n){
if (n < 10) return "0" + n else return "" + n
}
t = Math.max(time - delay,0);
clockTime = Math.max(clockStart + rate*(t - inPoint),0);t = Math.floor(clockTime);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
min + ":" + padZero(sec)
Dan
-
Adam Fram
October 29, 2015 at 10:16 pmDan,
The countdown/up script on your website is super helpful and very customizable so thank you for that genius piece of code.
I noticed that the counter seems to round in the wrong direction when counting. Here’s an example of it counting down: 59.02, 59.01, 58.00, 58.99, 58.98
Is there a simple code solution related to the padding that I can use for this?Thanks!
-Adam Fram
adamfram.comrate = -1;
clockStart = 600.00;function padZero(n){
if (n < 10) return "0" + n else return "" + n
}clockTime = clockStart + rate*(time - inPoint);
if (clockTime < 0){
sign = "-";
clockTime = -clockTime;
}else{
sign = "";
}t = Math.floor(clockTime);
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(2).substr(-2);
padZero(min) + ":" + padZero(sec) + "." + ms
-
Dan Ebberts
October 30, 2015 at 2:51 amThis should work better:
rate = -1;
clockStart = 600.00;
function padZero(n){
if (n < 10) return "0" + n else return "" + n
}
clockTime = clockStart + rate*(time - inPoint);
t = clockTime.toFixed(2);
ms = t.substr(-2);
t = parseInt(t,10);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
padZero(min) + ":" + padZero(sec) + "." + ms
Dan
-
Pedro Arias
February 23, 2016 at 4:00 pmHow can you get this Expression to ease out (decay)? I’ve tried inputting Math.exp(decay*t) but I can’t get the count up to slow down at the end.
numDecimals = 0;
commas = false;
dollarSign = false;
beginCount = 0;
endCount = 672;
dur = 2;
dec = .5;t = time - inPoint;
s = linear (t , 0, dur, beginCount, endCount).toFixed(numDecimals);prefix = "";
if (s[0] == "-"){
prefix = "-";
s = s.substr(1);
}
if(dollarSign) prefix += "$";if (commas){
decimals = "";
if (numDecimals > 0){
decimals = s.substr(-(numDecimals + 1));
s = s.substr(0,s.length - (numDecimals + 1));
}
outStr = s.substr(-s.length, (s.length-1)%3 +1);
for (i = Math.floor((s.length-1)/3); i > 0; i--){
outStr += "," + s.substr(-i*3,3);
}
prefix + outStr + decimals;
}else{
prefix + s ;}
-
Dale Sandberg
March 11, 2016 at 9:34 pmDan,
I want to start off by saying thank you for all the work you do answering question on these forums.
I’ve been using this countdown expression for some time now, but in a 10 minute interval. Without fail, the countdown always displays time “4:04” (four minutes and four seconds) as “5:14” (five minutes and fourteen seconds). I’ve tried change the delay to 0, 1, etc… but no matter what 4:04 always is replaced with 5:14.
Thoughts on why this happens and possibly a solution for the issue?
Here is a video showing my issue. 9880_countdownvideo.mov.zip
rate = -1;
clockStart = 600;
delay = 2;function padZero(n){
if (n < 10) return "0" + n else return "" + n
}
t = Math.max(time - delay,0);
clockTime = Math.max(clockStart + rate*(t - inPoint),0);t = Math.floor(clockTime);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
min + ":" + padZero(sec) -
Dan Ebberts
March 12, 2016 at 7:40 pmThat’s fascinating. I can create the same result, although sometimes it’s the reverse (4:04 where 5:14 should be). It seems like it might be a caching issue of some kind where the two results are seen as equivalent (= already rendered) by the caching system. That’s just speculation though.
Dan
-
Dale Sandberg
March 13, 2016 at 2:24 amDan, thanks for the quick reply. I believe you are correct about the cache issue. I just changed the opacity of that 1 second to 99% and it seems to render those frames fresh instead of pulling them from the cache. The time is correct when opacity is set to 99%.
Reply to this Discussion! Login or Sign Up