• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Expression counter with commas and two decimal points

Community Beginner ,
Apr 12, 2016 Apr 12, 2016

Copy link to clipboard

Copied

Hello all,

I'm trying to get an expression counter with commas and two decimal points. I have the comma taken care of, but I can't seem to get the two decimal points to work.

Here's my current expression. As you'll see, nothing in there about decimal points. Nothing I've tried has worked for me. Thoughts?

var num = effect("Slider Control")("Slider")

num = Comma(num);

[num]

function Comma(number)

{

number = '' + Math.round(number);

if (number.length > 3)

{

var mod = number.length % 3;

var output = (mod > 0 ? (number.substring(0,mod)) : '');

for (i=0 ; i < Math.floor(number.length / 3); i++)

{

if ((mod == 0) && (i == 0))

output += number.substring(mod+ 3 * i, mod + 3 * i + 3);

else

output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);

}

return (output);

}

else return number;

}

TOPICS
Expressions

Views

15.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 12, 2016 Apr 12, 2016

Copy link to clipboard

Copied

‌Try this: Dan Ebberts's Universal Timer

Or here is my preset for that kind of thing. It's Dan's timer on steroids. universalTimer.ffx

By the way, typing counter expression or count with decimals or even timer In the search help field would've taken you directly to Dan's universal timer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 13, 2016 Apr 13, 2016

Copy link to clipboard

Copied

Great! Worked like a charm. Thanks Rick! One other quick question...is there a way to force the dollar sign to be superscript? I've tried something simple like: string.sup()

But that didn't work. Thoughts?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

You Can use a Scale+position Animator, and "lock" it to the dollar sign with the range selector (letter index and not percentage), if it's on the right side of the counter the start index should be 0 and the end index should be 1, if it's on the left side you will need an expression that "knows" where the dollar sign index is and set the start value to the dollar index and the end to the index-1.

You can also Skip the code and expressions and use this cool Counter Preset:

http://www.vdodna.com/products/counter-preset/

Cheers!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

Very similar to the one that I shared for free... just saying

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 16, 2020 Sep 16, 2020

Copy link to clipboard

Copied

Hi,

 

How to change the comma to a dot??

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 16, 2020 Sep 16, 2020

Copy link to clipboard

Copied

Look for the character you want to change in the expression. The comma will look like this "," or ','

 

Change the character. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

If you guys are interested I have created a tutorial with a bunch of expression for countdown and counters, I have also included to after effects source file so you can add it to your own project.

 

https://blog.motionisland.com/after-effects-counter-templates-projects/

 

Hope it will help you

 

Best

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 28, 2023 Sep 28, 2023

Copy link to clipboard

Copied

LATEST

Check out this helpful After Effects tutorial on countdowns and counters, along with free project files: [Link to Tutorial]. You can also find more free After Effects resources at https://riztagar.com/. Improve your skills with their easy-to-follow tutorials and project files!

riztagar

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines