Timer Controls
Copy link to clipboard
Copied
I am having issues using expressions with a countdown timer. I've found some script but I keep getting errors saying that it is not a functioning code. This is the current code I use
rateOfSpeed=1;
clockStartTime = thisComp.layer(“slider”).effect(“Slider Control”)(“Slider”)*60;
clockTimeNumber = Math.floor(clockStartTime – rateOfSpeed*time);
function addZero(n) {
if (n<10) return “0” + n else return n;
}
minutes = Math.floor(clockTimeNumber/60);
seconds = clockTimeNumber%60;
if (clockStartTime > 0 && time < clockStartTime) {
addZero(minutes) + “:” + addZero(seconds);
} else {“00:00”}
For some reason, the errors saying "Syntax error: unexpected token else." I am assuming that there is something I'm missing, but my skills with expressions aren't that good. Any advice?
Copy link to clipboard
Copied
Easy enough. You botched your brackets on line 6. This is better:
function addZero(n){
if (n<10) {return “0” + n} else {return n}
};
Mylenium
Copy link to clipboard
Copied
Ah, I see thank you!. I had a feeling that I had missed something.
Copy link to clipboard
Copied
Yes, Myleniums hint should solve the issue.
If you are looking for a more flexible solution where you can customize the formatting of your counter easily, my Counter Numbers iExpression is also an option.
(iExpressions is an extension that is available at aescripts).
Copy link to clipboard
Copied
I'll take a look at it. It might help me out in the future.

