Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Counter script: space between numbers

  • Counter script: space between numbers

    Posted by Etienne Buteau on May 14, 2012 at 2:21 am

    Hi !

    I want to do a counter to 100 000 to 1 000 000.

    Here is the script I use:

    startT = 1;
    endT = 5;
    beginVal = 100000;
    endVal = 1000000;
    t = linear(time,startT,endT,beginVal,endVal);
    t.toFixed(0)

    Everything is working fine. But I would like to keep the space between the numbers (100 000 instead of 100000)

    A friend told me to put this script ” .replace(/(d{3})/gi, ‘$1 ‘) ” at the end of my script. It work with 100 000 but not for 1 million: 100 000 0

    Someone can help me ?

    thank you !

    Walter Soyka replied 4 years, 8 months ago 5 Members · 5 Replies
  • 5 Replies
  • Etienne Buteau

    May 14, 2012 at 9:31 pm

    up !

  • Dan Fredley

    May 16, 2012 at 12:35 pm

    Try this:

    startT = 1;
    endT = 5;
    beginVal = 100000;
    endVal = 1000000;
    t = linear(time,startT,endT,beginVal,endVal);
    t += "";
    t.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 ");

    Dan Fredley

  • Marcin Staszewski

    April 24, 2016 at 2:36 pm

    Thanks Dan!
    I know this thread is pretty old, but it still saved me today 🙂

  • Werner Botha

    August 25, 2021 at 12:57 pm

    If I want to add math.round to this, where would it go?

  • Walter Soyka

    August 25, 2021 at 3:41 pm

    Add Math.round around linear, like this:

    startT = 1;

    endT = 5;

    beginVal = 100000;

    endVal = 1000037;

    t = Math.round(linear(time,startT,endT,beginVal,endVal));

    t += "";

    t.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 ");

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