Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Number increasing expression starting from “0000” not “0”

  • Number increasing expression starting from “0000” not “0”

    Posted by Valo Balmaseda on June 27, 2011 at 11:05 pm

    Hello,

    i need some help or advice about an expression to be used on text-number layer.

    I put this expression to increment and control through a slider, but my problem is, that’s starting with just a “0” instead of “000000”

    base = linear(effect(“Slider Control”)(“Slider”), 0, 1, 000000, 100000);
    rounded = Math.floor(base);
    str = rounded+””;
    len = str.length;
    num = “”;
    nospace = “”;
    i = len-1;
    while(i >= 0)
    {
    num = str[i] + num;
    nospace = str[i]+nospace;
    if ((nospace.length)%3 == 0) num = ” ” + num;
    i–;
    }
    num

    I imagine that’s simple answer but my expression levels are not good enough…

    Thanks!

    base = linear(effect("Slider Control")("Slider"), 0, 1, 000000, 100000);
    rounded = Math.floor(base);
    str = rounded+"";
    len = str.length;
    num = "";
    nospace = "";
    i = len-1;
    while(i >= 0)
    {
    num = str[i] + num;
    nospace = str[i]+nospace;
    if ((nospace.length)%3 == 0) num = " " + num;
    i--;
    }
    num

    Valo Balmaseda

    Valo Balmaseda replied 13 years, 1 month ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    June 27, 2011 at 11:29 pm

    Try it this way:


    base = linear(effect("Slider Control")("Slider"), 0, 1, 000000, 100000);
    rounded = Math.floor(base);
    str = "" + rounded;
    while (str.length < 6) str = "0" + str;
    len = str.length;
    num = "";
    nospace = "";
    i = len-1;
    while(i >= 0)
    {
    num = str[i] + num;
    nospace = str[i]+nospace;
    if ((nospace.length)%3 == 0) num = " " + num;
    i--;
    }
    num

    Dan

  • Valo Balmaseda

    June 27, 2011 at 11:31 pm

    Excelent Dan!

    It works very good!

    Hey man, thank you so much for your fast reply, and solution!

    Regards

    Valo Balmaseda

  • Valo Balmaseda

    March 30, 2013 at 7:44 am

    Hi all,

    a new question after some time ago..

    On the previous increment numbers expression’s, my new problem is how to add a comma since the 1000’s.
    So, from 0 to 999, it doesn’t appear a comma, but at 1000’s, the expression adds a comma to separate thousandths.

    Thanks!

    base = linear(effect("Slider Control")("Slider"), 0, 1, 000000, 100000);
    rounded = Math.floor(base);
    str = rounded+"";
    len = str.length;
    num = "";
    nospace = "";
    i = len-1;
    while(i >= 0)
    {
    num = str[i] + num;
    nospace = str[i]+nospace;
    if ((nospace.length)%3 == 0) num = " " + num;
    i--;
    }
    num

    Valo Balmaseda

  • Valo Balmaseda

    March 30, 2013 at 7:46 am

    Hi all,

    a new question after some time ago..

    On the previous increment numbers expression’s, my new problem is how to add a comma since the 1000’s.
    So, from 0 to 999, it doesn’t appear a comma, but at 1000’s, the expression adds a comma to separate thousandths.

    Thanks!

    base = linear(effect("Slider Control")("Slider"), 0, 1, 000000, 100000);
    rounded = Math.floor(base);
    str = "" + rounded;
    while (str.length &lt; 6) str = "0" + str;
    len = str.length;
    num = "";
    nospace = "";
    i = len-1;
    while(i >= 0)
    {
    num = str[i] + num;
    nospace = str[i]+nospace;
    if ((nospace.length)%3 == 0) num = " " + num;
    i--;
    }
    num

    Valo Balmaseda

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