Animate Numbers Counting Up in After Effects

May 19, 2016

animate number counter in after effects

Learn how to animate numbers counting up in After Effects with just a text layer and some expressions code- no keyframing required!

There are several different methods for animating numbers counting up in After Effects. In the past I’ve used slider controls and I’ve even used the Numbers effect (don’t do that) but the method below is by far my favorite and will soon become part of all our infographics templates.

In this post I’ll show you how to animate numbers counting up with a Text layer and NO keyframes! It’s gonna get a little nerdy but I promise it’s not too difficult to follow.

For this example we’ll animate a number from 0 to 1000 by applying this nifty expression to animate with no keyframes!

1. Create a text layer and type “1000”.

2. Hold the Alt or Option key while clicking on the stopwatch for the Text layer’s Source Text property

number counter source text after effects

3. Then paste this code:
start=parseInt(thisLayer.text.sourceText="0");
end=parseInt(text.sourceText);
val=Math.round(easeOut(time, startTime, 4,start, end));

So what does this all mean exactly?

start=parseInt(thisLayer.text.sourceText=”0″);>> You can type whatever number you want in the quotations

end=parseInt(text.sourceText);>> The “ending” number is whatever text you type for the actual text layer

val=Math.round(easeOut(time, startTime, 4,start, end));>> The last line basically says “as time elapses from the Start of the layer to a number you specify representing seconds, the number will animate from the number in quotations to the number typed in the text layer.

You should see your text animate from 0 to a 1000 in 4 seconds. Pretty cool!!

But what if you need to add a comma to 1000?

Thanks to Nick Khoo for showing the world how to do that! You can see his method here.

Below we’ve added a part of his code to our expression:

start=parseInt(thisLayer.text.sourceText="0");
end=parseInt(text.sourceText);
val=Math.round(easeOut(time, startTime, 2,start, end));
s=""+ val;
if (s.length > 3){
s.substr(0, s.length -3) + "," + s.substr(-3);
}else{
s
}

I know what you’re thinking…

“But but but….What about two commas?!”

A YouTuber left a comment on Nick Khoo’s video that worked that all out:

start=parseInt(thisLayer.text.sourceText="0");
end=parseInt(text.sourceText);
val=Math.round(easeOut(time, startTime, 2,start, end));
s=""+ val;
if (s.length > 6){
s.substr(0, s.length -6) + "," + (s.substr(1, s.length -4) + "," + s.substr(-3));
}else{
if (s.length > 3){
s.substr(0, s.length -3) + "," + s.substr(-3);
}else{
s
}}

animate numbers text counting up in after effects no keyframes

Hopefully that little bit of code comes in handy next time you need to do the ever so boring task of animating numbers!





Leave a comment

Comments will be approved before showing up.


Also in Blog – FluxVFX

Data-Driven Expressions for After Effects 2019

November 20, 2018

Data-driven expressions are a powerful way to easily make infographics templates from spreadsheets in After Effects and export for use in Premiere Pro! I recently worked with Adobe Stock to create data-driven templates available to download *for free* here!

In a previous post I cover some of the basics for creating a .csv file and how to use it in After Effects 2019. Today I’d like to share expressions for working with data; some of them utilize the new Javascript expressions engine in After Effects 2019. Hopefully these will spark your imagination to see what’s possible with data-driven animations!

 

View full article →

Data-Driven Motion Graphics Templates in After Effects 2019

November 20, 2018

Creating infographic animations is easier than ever with Adobe’s new csv spreadsheet enabled data-driven motion graphics templates feature in After Effects 2019. You can create and update infographics (and really any text-based animation) from a spreadsheet in both After Effects and Premiere Pro 2019. The free data-driven motion graphics templates can be downloaded here and even more are currently in the works!

It was very exciting to get a first look at this feature and learned A TON along the way. Check out this post where I share expressions for working with data that utilizes the new Javascript expressions engine in After Effects 2019. Hopefully these will spark your imagination to see what’s possible with data-driven animations!

 

View full article →

Free FluxVFX Motion Graphics Templates on Adobe Stock

November 21, 2017

Get ready for editable Motion Graphics Templates in Premiere Pro 2018!

Hey there!

I recently had the honor of working with Adobe to create a set of 50 free Motion Graphics Templates (aka mogrts!) for Adobe Stock. We’re very excited about the new file format and hope you are too!

After hearing about the struggles some video producers have using After Effects I knew Mogrts would be a game changer.

 

 

 

View full article →