ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Comma instead dot in a number counter

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hugo Gomez
Comma instead dot in a number counter
on Jun 22, 2017 at 10:25:21 am

Hi,

First at all I would like to say that I have very little idea about expressions, it is not a language I understand, but touching here and there sometimes I manage to get what I want, most of the time by luck.

I am using a number counter expression that works great, however now I have to do the video in other languages and instead the number using "dot", must use "comma"

For English: 2.5
For the other languages 2,5

Is possible to get that modifying this code?

(Sorry for my English, this is not my native language)

numDecimals = 1
;
commas = true;
beginCount = 0.1;
endCount = 5.9;
dur = 1;

t = time - inPoint;
s = ease (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

prefix = "";
if (s[0] == "-"){
prefix = "-";
s = s.substr(1);
}

if (commas){
decimals = "";
if (numDecimals > 0){
decimals = s.substr(-(numDecimals + 1));
s = s.substr(0,s.length - (numDecimals + 1));
}
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);
}
prefix + outStr + decimals;
}else{
prefix + s;
}


Return to posts index

Dan Ebberts
Re: Comma instead dot in a number counter
on Jun 22, 2017 at 3:53:39 pm

Try changing this line:

s = ease (t, 0, dur, beginCount, endCount).toFixed(numDecimals);


to this:

s = ease (t, 0, dur, beginCount, endCount).toFixed(numDecimals);
s = s.replace(".",",");


Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]