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

Countdown timer expression error

New Here ,
Dec 27, 2022 Dec 27, 2022

Copy link to clipboard

Copied

I'm trying to make a countdown timer from textScreenshot 2022-12-27 at 11.58.29.png, counting down from 10 minutes. I'm using an expression on a Slider Control that has always worked but it seems like it doesn't work with the latest update.

 

This is the expression I'm using: 

slider = Math.round(effect("Slider Control")("Slider"))      

sec = slider%60 

min = Math.floor(slider/60) 

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

addZero(min) + ":" + addZero(sec)

 

I got the error on line 4:'' Error; SyntaxError; Unexpected 'else'Screenshot 2022-12-27 at 12.00.40.png

 

If anyone has any suggestions I would really appraciate the help! 

TOPICS
Expressions

Views

915

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Dec 27, 2022 Dec 27, 2022

All explained here:

 

https://helpx.adobe.com/after-effects/using/legacy-and-extend-script-engine.html

 

Sloppy expressions are no longer acceptable. Your if()else{} statement needs to be properly encased/ terminated with curly brackets. Reformatting also helps to detect such errors:

 

slider = Math.round(effect("Slider Control")("Slider"))      

sec = slider%60 
min = Math.floor(slider/60) 

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

addZero(min) + ":" + addZero(sec)

 

M

...

Votes

Translate

Translate
LEGEND ,
Dec 27, 2022 Dec 27, 2022

Copy link to clipboard

Copied

All explained here:

 

https://helpx.adobe.com/after-effects/using/legacy-and-extend-script-engine.html

 

Sloppy expressions are no longer acceptable. Your if()else{} statement needs to be properly encased/ terminated with curly brackets. Reformatting also helps to detect such errors:

 

slider = Math.round(effect("Slider Control")("Slider"))      

sec = slider%60 
min = Math.floor(slider/60) 

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

addZero(min) + ":" + addZero(sec)

 

Mylenium

Votes

Translate

Translate

Report

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
New Here ,
Dec 27, 2022 Dec 27, 2022

Copy link to clipboard

Copied

LATEST

Thank you!

Votes

Translate

Translate

Report

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