ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to add 0 in a counter to show 00, 01, 02... ?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hassan Ganari
How to add 0 in a counter to show 00, 01, 02... ?
on Sep 10, 2019 at 9:42:23 am

Hi everyone,

I want to add a 0 to the counter when it's going from 0 to 9.
The result should be like this :
%00, %01, %02... then %10, %11

Struggling for hours now but I know you guys can help.

Thank you so much.

Hassan

number = thisComp.layer("PERCENTAGE").effect("Percentage RIGHT")("Slider");
rounded = Math.round(number *100) /100;
number2 = "%"""+rounded.toFixed(1);


Return to posts index

Dan Ebberts
Re: How to add 0 in a counter to show 00, 01, 02... ?
on Sep 10, 2019 at 4:14:42 pm

Try this:

num = thisComp.layer("PERCENTAGE").effect("Percentage RIGHT")("Slider");
n = Math.round(num);
(n < 10 ? "0" : "") + n


Dan



Return to posts index

Hassan Ganari
Re: How to add 0 in a counter to show 00, 01, 02... ?
on Sep 11, 2019 at 11:10:37 am

Thanks a lot Dan,
You are a HERO.

I changed the expression a little to add the % symbol like this :

n= thisComp.layer("PERCENTAGE").effect("Percentage_RIGHT")("Slider");
n2= Math.round(n *100) /100;
"%"+(n2 < 10 ? "0" : "") + n2


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]