Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects percentage counter problem…

  • Declan Smith

    February 16, 2012 at 12:39 am

    I think I know what you mean, when the numbers change each character slightly shifts either left or right ?

    It looks like it is the kerning. I changed the kerning from metrics to 0 for the “American Type” font (which had the wobbling) and this appears to have fixed it. Worth trying. I set the kerning for each character position separately. I set the static text as 100%, selected all the text and changed the kerning to 0.

    Declan Smith
    https://www.madpanic.tv
    FCS3 / After Effects CS5 / Combustion / Canon 7D / Canon XL2

  • Nick Natteau

    February 16, 2012 at 1:07 am

    Thanks very much Declan, yes that’s exactly what I meant…the characters shifting slightly left/right

    The font that was doing this is “KP Duty” – a stencil font downloaded from “myfonts.com”

    KP Duty.

    Not sure why that particular font would do this when animated in a decimal counter expression.
    But yes, some appear to do it while others don’t. But thanks again.

  • Nick Natteau

    February 17, 2012 at 7:53 pm

    Hi Kevin,

    Sorry to bother you again. Can you just tell me how to insert commas into my figures in the expression.

    Tried searching the cow forums, but can’t figure out how to simply add commas to my numbers:

    e.g. 12567890…12,567,790

  • Declan Smith

    February 17, 2012 at 8:18 pm

    You could use something like what is described here:
    https://www.mredkj.com/javascript/numberFormat.html

    i.e., in your source text, assuming that the number value is in a variable called nStr:

    This basically runs over the number and inserts the commas for every three digits, then adds anything after the decimal point if it were supplied.

    nStr += ”;
    x = nStr.split(‘.’);
    x1 = x[0];
    x2 = x.length > 1 ? ‘.’ + x[1] : ”;
    var rgx = /(d+)(d{3})/;
    while (rgx.test(x1)) {
    x1 = x1.replace(rgx, ‘$1’ + ‘,’ + ‘$2’);
    }
    x1+x2

    Given that nStr is 100000 result would be 100,000
    nStr=1234.56 result=1,234.56
    nStr=100000000 result=100,000,000

    etc etc

    Declan Smith
    https://www.madpanic.tv
    FCS3 / After Effects CS5 / Combustion / Canon 7D / Canon XL2

  • Declan Smith

    February 17, 2012 at 8:34 pm

    More efficient way of adding in commas:

    str=”1232224.2″;
    regEx = new RegExp(‘(-?[0-9]+)([0-9]{3})’);
    while(regEx.test(str)) {
                             str = str.replace(regEx, ‘$1,$2’);
    }
    str;

    Declan Smith
    https://www.madpanic.tv
    FCS3 / After Effects CS5 / Combustion / Canon 7D / Canon XL2

  • Nick Natteau

    February 17, 2012 at 8:40 pm

    Hi Declan,

    Thanks very much but I still can’t get it to work. Kevin had me insert this for percentages:

    effect(“Slider Control”)(“Slider”).value.toFixed(0)+”%”

    But I changed it to: effect(“Slider Control”)(“Slider”).value.toFixed(0)+”Miles” for Miles or “Km”
    if I needed to show a decimal counter counting up a distance.

    That text that you gave me…where would it be inserted in this script:

    effect(“Slider Control”)(“Slider”).value.toFixed(0)+” Miles” Before? After? within???

  • Declan Smith

    February 17, 2012 at 9:08 pm

    Hi Nick

    You would have your expression something like below. The first line grabs the value from the slider in the format you want it, with the text suffix of “Miles”. Then the regular expression does the work of searching groups of three numbers. The very last line returns the final formatted value.

    str=effect(“Slider Control”)(“Slider”).value.toFixed(0)+”Miles”;

    regEx = new RegExp(‘(.*[0-9]+)([0-9]{3})’);
    while(regEx.test(str)) {
                             str = str.replace(regEx, ‘$1,$2’);
    }
    str

    Declan Smith
    https://www.madpanic.tv
    FCS3 / After Effects CS5 / Combustion / Canon 7D / Canon XL2

  • Declan Smith

    February 17, 2012 at 9:32 pm

    Nick

    Here it all is as a one liner


    (effect("Slider Control")("Slider").value.toFixed(0)+" Miles").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");

    Enjoy!

    Declan Smith
    https://www.madpanic.tv
    FCS3 / After Effects CS5 / Combustion / Canon 7D / Canon XL2

  • Liran Tabib

    May 11, 2018 at 1:26 pm

    Hi Nick
    Expression Based counters have their flaws, but they they are easy to create and animate (until you tackle something like this).
    If using the paragraph alignment don’t resolve this I recommend using our Counter Preset to solve the alignment issue.

    Best Regrads

    Liran Tabib
    http://www.vdodna.com

  • Matthew Ingram

    May 1, 2020 at 2:58 pm

    should anyone discover this thread – the answer is to uncheck proportional spacing in the Numbers effect.

Page 2 of 2

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