Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Timer Controls

Explorer ,
May 19, 2020 May 19, 2020

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?

TOPICS
Expressions , FAQ , Scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2020 May 19, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2020 Jun 10, 2020

Ah, I see thank you!. I had a feeling that I had missed something.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2020 May 20, 2020

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.

screenshot_2020-01-07_15.34.00expand image

(iExpressions is an extension that is available at aescripts).

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2020 Jun 10, 2020
LATEST

I'll take a look at it. It might help me out in the future.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines