Skip to main content
ItzBlue
Participant
November 29, 2018
Answered

Creating a Sports Scoreboard Timer in AE

  • November 29, 2018
  • 2 replies
  • 1525 views

I have ventured Far and Wide to find the problem with an expression i am using. I am creating a Scoreboard timer for a Soccer game recently recorded. However i have met numerous problems with it. once i get to > 10 mins there is a zero constantly in the minutes column. i see the issues but im not sure what expression i could use to right the wrong. Any help would be greatly appreciated.

sec = Math.floor(time%60);

min = Math.floor(time/60);

if(sec<10)

{"0" + min +":0" + sec;}

else

{"0" + min +":" + sec;}

Thank you

This topic has been closed for replies.
Correct answer Dan Ebberts

Try it this way:

function padZero(n){

  return (n < 10 ? "0" : "") + n;

}

sec = Math.floor(time%60);

min = Math.floor(time/60);

padZero(min) + ":" + padZero(sec)

Dan

2 replies

Participant
November 30, 2023

In Adobe After Effects, crafting a sports scoreboard  timer is a seamless process that blends functionality with creativity. The software's intuitive interface empowers users to design dynamic and visually engaging timers, enhancing the overall viewing experience. With precise control over animations and transitions, AE enables seamless integration of timers into sports broadcasts or presentations. Its versatility, coupled with a myriad of customization options, makes AE a go-to tool for producing professional and captivating sports scoreboards.

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
November 29, 2018

Try it this way:

function padZero(n){

  return (n < 10 ? "0" : "") + n;

}

sec = Math.floor(time%60);

min = Math.floor(time/60);

padZero(min) + ":" + padZero(sec)

Dan

sudeshprathapv
Known Participant
November 30, 2018

for people who wanna understand the above expression: (still I couldnt understand how you used the a

The padzero( ) function makes the text a fixed width, padding on the left with zeros if necessary.

This function has two parameters:

text – the original text.

width – desired number of characters.

Description

This function makes the text a fixed width. If the text is shorter than the specified width, it is padded with 0s on the left (i.e. the text is right justified). If it is longer than the specified width, it is cut off on the left.

padzero("abcdxyz",12) ☞ 00000abcdxyz
padzero("85.22",7)    ☞ 0085.22

source: padzero( function


below expression will work?

sec = Math.floor(time%60);

min=Math.floor(time/60)

M=padZero("min",3);

S=padZero("sec",3);

M+":"+S

sudeshprathapv
Known Participant
November 30, 2018

can you explain this section?

function padZero(n){
  return (n < 10 ? "0" : "") + n;

it it was like below, I would have understood.

function padZero(n){
  return (n < 10 ? "0") + n;

why do we need to add --->  :""    <--- in the expression.
I don't understand that part alone