Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to add 0 in a counter to show 00, 01, 02… ?

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

    Posted by Hassan Ganari on September 10, 2019 at 9:42 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);

    Hassan Ganari replied 6 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 10, 2019 at 4:14 pm

    Try this:

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

    Dan

  • Hassan Ganari

    September 11, 2019 at 11:10 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

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy