ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Number Counter Expression

FAQ   •   VIEW ALL
 Number Counter Expression on Oct 20, 2016 at 1:53:55 am

Hey all,

I'm trying to animate a text layer to increase from 0 to 3,000,000 however I've run into a couple of issues. I quickly figured out that the slider control expression is capped to 1,000,000 so after reading over a few posts about how to get around this I've ended up with this code which has been applied to an empty text layer (keep in mind I am completely new to writing code like this and thus have copied this from another user's post with only a basic understanding of how it functions). My issue is that while this code works the way I want, it begins counting at the start of my timeline, instead of where I need it to begin, and if I physically drag the text layer to the point I need, the number freezes on 3000000 instead of counting upwards from zero when played back. Is there something I could add to this expression so that it starts at a specified point in my composition?

```startCount = 0; endCount = 3000000; countDur = 14; Math.round(linear(time,0,countDur,startCount,endCount))```

 Re: Number Counter Expressionon Oct 20, 2016 at 4:13:11 am

Try this:

tStart = 3; // start 3 seconds into comp
startCount = 0;
endCount = 3000000;
countDur = 14;
t = Math.max(time-tStart,0);
Math.round(linear(t,0,countDur,startCount,endCount))

Dan

 Re: Number Counter Expressionon Oct 24, 2016 at 4:52:27 am

Thanks Dan, it worked a treat!

 Re: Number Counter Expressionon May 10, 2018 at 7:04:40 am

there is a different approach to solve this by Linking the Source Text value to a Slider/Point Control and animating them.
Counter Preset is based on that solution so you can create any Counter and running numbers animation, with keyframes. I hope you will find it useful. you can get it here:
http://www.vdodna.com/products/counter-preset/

Cheers!

Liran Tabib
http://www.vdodna.com