Copy link to clipboard
Copied
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
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
function padZero(n){
return (n < 10 ? "0" : "") + n;
Result at 5 sec ==> 00:05
Result at 1:30 min ==> 01:30
function padZero(n){
return (n < 10 ? "Y" : "N") + n;
Result at 5 sec ==> 00:Y5
Result at 1:30 min ==> 01:N30
I think I understood.
Copy link to clipboard
Copied
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.