Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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/1031788...
Hope it helps.
Thanks,
Nishu
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Try to post some screenshots
Copy link to clipboard
Copied
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