Skip to main content
Participant
August 13, 2021
Question

Need help with commas in numbers

  • August 13, 2021
  • 4 replies
  • 1201 views

I am a total novice but making a counter. It is counting from $10,000 up to $1,000,000. I have it counting just like I want, but I need to add commas to the number. What can I add to this code to make commas show up? 

I have this code in the expression 

 

"$"+effect("Slider Control")("Slider").value.toFixed(0)

 

Thank you! 

This topic has been closed for replies.

4 replies

Mylenium
Legend
August 15, 2021

Without any info about your actual render process nobody can tell you much. If you render via AME start by rendering directly from AE instead to prevent issues with expressions not evaluating correctly. Everything else will require more information.

 

Mylenium

Community Expert
August 14, 2021

Dan Ebberts has published a universal counter that does everything you want it to do. 

 

Find it here: Dan Ebberts Universal Counter.

 

That is where OussK's answer came from. Dan is one of, if not the best resources for expressions.

Participant
August 15, 2021

This works and previews correctly but when I export it, it is not correct and shows just the layer name as still instead of the counting numbers. Have you seen this before? 

OussK
Community Expert
Community Expert
August 15, 2021

Try to post some screenshots 

OussK
Community Expert
Community Expert
August 14, 2021

try this expression, you should change the value from the expression it self or you can create a slider control if you want 

 

commas = true ;
numDecimals = 0;
dollarSign = true;
beginCount = 100;
endCount = 3000;
dur = 3;

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

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

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;
}
nishu_kush
Community Manager
Community Manager
August 13, 2021

Hi marciej79878702,

 

Thanks for writing in.

Here's a similar discussion with a correct answer: https://community.adobe.com/t5/after-effects/putting-a-comma-in-an-after-effects-counter/m-p/10317880 

Hope it helps.

 

Thanks,

Nishu