Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Count-up expression

  • Count-up expression

    Posted by Deniz Nasif on October 25, 2011 at 5:59 pm

    Hi,

    I currently have numbers counting up using the following expression:

    beginTime = 0;
    endTime = 15.02;
    startVal = 0.00;
    endVal = 15;

    Math.round(linear(time,beginTime,endTime,startVal,endVal))

    However, I want to add decimals to it, so it basically says 0.00. Any help would be greatly appreciated.
    Many thanks in advance.

    Dan Ebberts replied 14 years, 4 months ago 3 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    October 25, 2011 at 10:30 pm

    If you just want to add “.00” to the result, change the last line to this:

    Math.round(linear(time,beginTime,endTime,startVal,endVal)) + “.00”

    If you actually want two decimal places in the result, you would change it to this:

    linear(time,beginTime,endTime,startVal,endVal).toFixed(2)

    Dan

  • Deniz Nasif

    October 26, 2011 at 6:14 am

    Excellent Dan. Thank you very much for your help 🙂

  • George Fragakis

    January 23, 2012 at 9:45 pm

    hey, first post here so be gentle. 🙂

    I wan’t to get the same effect only i need my final number to have “.” between digits.

    Specifically I need my count to start from €0 and get to €50.000.000

    I have this expression (which I found here on another amazing thread):

    beginTime = 0;
    endTime = 5;
    startVal = 100;
    endVal = 1200000,00;

    “€” + Math.round(linear(time,beginTime,endTime,startVal,endVal))

    How can I get it to work with “.” in between ? Thank you so much in advance

    beginTime = 0;
    endTime = 5;
    startVal = 100;
    endVal = 1200000,00;

  • Dan Ebberts

    January 23, 2012 at 11:42 pm

    This should work:


    beginTime = 0;
    endTime = 5;
    startVal = 0;
    endVal = 50000000;

    s = "" + Math.round(linear(time, beginTime, endTime, startVal, endVal))
    prefix = "€";
    outStr = s.substr(-s.length, (s.length-1)%3 +1);
    for (i = Math.floor((s.length-1)/3); i > 0; i--){
    outStr += "." + s.substr(-i*3,3);
    }
    "€" + outStr

    Dan

  • George Fragakis

    January 26, 2012 at 11:27 pm

    worked like a charm Dan, thank you. Now to add ,88 at the end? (or any other decimal for that matter?)

  • Dan Ebberts

    January 27, 2012 at 12:53 am

    I’m guessing this isn’t really what you want, but you could change the last line to:

    “€” + outStr +”,88″

    If what you really want is the fractional part of the count rounded to two digits, I really wish you had mentioned that to start with, before I ripped all that stuff out of the expression.

    Dan

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