Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Number Count Past 30,000

  • Number Count Past 30,000

    Posted by Lisa Ruiz on October 2, 2009 at 12:02 am

    I’m trying to do a number count up that goes to 45,050. I’ve tried an expression that uses the slider but I keep getting errors that disable the expression. It needs to count up from 0 to 45,050 and I need it to have the comma. Also I would like it to start when the layer starts not the comp, and have a duration line. Here’s the expression I was trying to use-

    s = effect("value")("Slider");
    m = effect("multiplier")("Slider"); //use for numbers greater than 1 million
    v = s*m; //value of counter

    function digits(Val, Digits)
    {var n = Val.toString();
    while (n.length < Digits) n = '0' + n; return n;}

    h = Math.floor(v);
    t = Math.floor(h / 1000);
    m = Math.floor(t / 1000);

    hd = digits(h-t * 1000, 3);
    td = digits(t-m * 1000, 3);

    if (v < 1000) {h} else if (v < 1000000) {t + "," + hd} else {m + "," + td + "," + hd}

    Wil Magness replied 14 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Wil Magness

    March 8, 2012 at 9:09 am

    If anyone else is looking for a solution to this problem, I believe you just need to change the single quotes around the zero, to double quotes.

    You would change:

    while (n.length < Digits) n = ‘0’ + n; return n;}

    to:

    while (n.length < Digits) n = “0” + n; return n;}

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