LIBRARY: Tutorials Reviews Interviews Editorials Features Business Authors RSS Feed

Express Yourself With Numbers! An After Effects Tutorial

COW Library : Adobe After Effects Tutorials : Andy Ford : Express Yourself With Numbers! An After Effects Tutorial
CreativeCOW presents Express Yourself With Numbers! An After Effects Tutorial -- Adobe After Effects Tutorial


CreativeCOW.net. All rights reserved.


Videos with number animations look slick. Why just display a static number or percentage on screen when you can have an animation scrolling the numbers up to your target number??

You can create many numeric animations efficiently with just one layer in your composition by applying the Slider Control effect and using an expression.




Videos with number animations look slick. Why just display a static number or percentage on screen when you can have an animation scrolling the numbers up to your target number? 

You can create many numeric animations efficiently with just one layer in your composition by applying the Slider Control effect and using an expression. How to write the correct expressions is a common topic in many forums, so this article will help you with the proper expression for rounding numbers, adding a select number of digits after the decimal point, or adding commas to large numbers. 

First, select your text layer and apply the Slider Control effect, which is found in Effect>Expression Controls. Reveal the Source Text field in your layer and Alt-click (Option-click on Mac) the stopwatch to open the expression area. Then, grab the pickwhip and drag it (click and hold) to the Slider Control’s Slider value.



You’ll see this text appear in the expression area:
effect("Slider Control")("Slider");

Now, the Slider controls the numeric value of your number in the text layer. This overrides anything typed in the layer. So, you can set keyframes for the slider value and After Effects will do the math for you to animate the numbers in-between those values on the timeline. However, be aware that After Effects will not round the number for you, so some frames of your animation may result in many digits after the decimal.



To alleviate this, you need to alter the expression to round the number. In my opinion, the quickest way to do this is to type Math.round at the beginning. When you type this and hit enter, parentheses will appear. You must move the “closed parentheses” to the end of the expression. It should look like this when complete: 
Math.round(effect(“Slider Control”)(“Slider));

Note that capitalization matters.  It has to be Math, not math. Now, you will have whole numbers with no decimal point.



If you want to add a comma to your number value so you get 1,000 instead of 1000, the expression is quite complex. This is where copy and paste come into play. Erase what you have in the expression area and paste this:
num = effect("Slider Control")("Slider").value.toFixed();
function addCommas(x) {
return x.toString().replace(/\B(?=(d{3})+(?!d))/g, ",");
},
addCommas(num);




Breaking this down, the top line provides what the variable equals. “Slider Control” is whatever you name the Slider Control effect. By default, it is Slider Control, but some people rename their effects.

Adding .value.toFixed() is important (note the capital “F”). Without this addition, your number will have a significant amount of digits after the decimal point. Inside the parentheses, you can add a numeric value. This value will be how many digits you want to see after the decimal point. To add two digits after the decimal point, the expression is as follows:
num = effect("Slider Control")("Slider").value.toFixed();
function addCommas(x) {
return x.toString().replace(/\B(?=(d{3})+(?!d))/g, ",");
}

addCommas(num);



The rest of the expression tells After Effects where to add a comma. These expressions make number animations easy and allow flexibility over rounding preference, the number of digits wanted after the decimal, and adding the comma.

Comments

Re: Express Yourself With Numbers! An After Effects Tutorial
by Wilson Santos
legal, tudo certo, obrigado
Re: Express Yourself With Numbers! An After Effects Tutorial
by Andy Ford
There is a \ before the B on the replace line. I will email the COW to have them update the copy.

-------------------------------------------------
Video Producer / Digital Marketer / Gear Reviewer / Author
-- http://www.AndyFordVideo.com --
Re: Express Yourself With Numbers! An After Effects Tutorial
by Wilson Santos
Olá Andy,
sua ideia de compartilhar a expressão foi excelente, o Math.round me serviu muito, porém eu não sou expert em AE por isso segue a screenshot. saudações
Re: Express Yourself With Numbers! An After Effects Tutorial
by Andy Ford
Hi Wilson,
I just tried is with your example and it worked for me. Did you setup the slider? Please send a screenshot.



-------------------------------------------------
Video Producer / Digital Marketer / Gear Reviewer / Author
-- http://www.AndyFordVideo.com --
Re: Express Yourself With Numbers! An After Effects Tutorial
by Wilson Santos
Olá Andy tudo bem?
Tentei usar sua expressão, porém a primeira expressão complexa não mostra a vírgula por que apresenta erro na função. A segunda função complexa não apresenta erro e mostra o ponto com duas casas decimais, mas também não mostra a vírgula, ou seja, o número aparece desta forma 1052.23
Saudações
Wilson


Related Articles / Tutorials:
Adobe After Effects
Create an Arrow or Pointer preset for After Effects

Create an Arrow or Pointer preset for After Effects

In this video tutorial, Graham reveals a really quick way to use Shape Layers to make an arrow preset that you can use to point to anything in Adobe After Effects.


Graham Quince
Adobe After Effects
Realistic Water Movement with Fractal Noise

Realistic Water Movement with Fractal Noise

In this tutorial video, Andy Ford shows you how to use the Fractal Noise effect in After Effects to add movement to water in a still photo

Feature
Andy Ford
Adobe After Effects
Adobe Creative Cloud September 2020 Update: Streamlined workflows that make storytelling easier

Adobe Creative Cloud September 2020 Update: Streamlined workflows that make storytelling easier

The current environment is forcing us to rethink and reimagine so much. Content creators, from broadcasters to streaming services to social video creators, are finding new ways of working that prove creativity and resourcefulness are inherent to the video industry. Adobe's Eric Philpott explores Adobe's developments in response to the ever evolving challenges we face today.

Editorial
Eric Philpott
Adobe After Effects
Makin' Planets! Saturn (with rings and shadows)

Makin' Planets! Saturn (with rings and shadows)

In this video, Graham shows how to make Saturn's rings using Polar Coordinates, then use an Alpha Invert Matte along with a simple expression to cut the rings out.


Graham Quince
Adobe After Effects
Text Box Background Preset in After Effects

Text Box Background Preset in After Effects

Graham's latest tutorial shows you how to combine several effects to generate a background for any text layer you add to an After Effects comp.

Tutorial
Graham Quince
Adobe After Effects
Makin' An Eclipse

Makin' An Eclipse

In this tutorial for Adobe After Effects, I use the Circle effect, Fractal Noise, Polar Coordinates and CC Light Rays to create a 2D solar eclipse.

Tutorial
Graham Quince
Adobe After Effects
How To Put Yourself In Any Movie Part 3: Keying Greenscreen

How To Put Yourself In Any Movie Part 3: Keying Greenscreen

Following the huge response to parts one and two of independent filmmaker Cody Pyper's Adobe Photoshop and After Effects tutorial series, "Put Yourself In Any Movie!", here is the truly EPIC series finale, which is the most complete single keying tutorial we've ever seen. It's all here, including Red Giant's Primatte Keyer, Premiere Pro's Lumetri Color Panel, AE's Keylight filter, everything you need to know about curves and levels, realistic blurs, shadows and VFX, and more! Did we mention that this is epic? EPIC!


Cody Pyper
Adobe After Effects
Makin' a 3D Nebula in Photoshop, Cinema4DLite, and After Effects

Makin' a 3D Nebula in Photoshop, Cinema4DLite, and After Effects

Graham continues his space tutorial series, featuring the Orion Nebula

Tutorial
Graham Quince
Adobe After Effects
Motion Tracking in After Effects

Motion Tracking in After Effects

During this short video tutorial, Andy Ford shows you how to apply Track Motion to aerial drone footage

Feature
Andy Ford
Adobe After Effects
Free Tablet and Phone Screen Replacement Tracking Images

Free Tablet and Phone Screen Replacement Tracking Images

Here's a giveaway for anyone interested in trying to do a screen replacement for their iPad, iPhone, Tablet or phone.


Graham Quince
MORE
© 2020 CreativeCOW.net All Rights Reserved
[TOP]