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

Countdown timer expression error

New Here ,
Dec 27, 2022 Dec 27, 2022

I'm trying to make a countdown timer from textScreenshot 2022-12-27 at 11.58.29.pngexpand image, 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.pngexpand image

 

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

TOPICS
Expressions
1.6K
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

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

...
Translate
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)

 

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

Thank you!

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