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
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
Adobe After Effects
Bring Images to Life with Paravent

Bring Images to Life with Paravent

Paravent is a useful script for Adobe After Effects, available for download for a donation or for free, and used to fold and unfold layers in After Effects.


Andy Ford
Adobe After Effects
Creating Fog with Fractal Noise

Creating Fog with Fractal Noise

This is just one quick example of many on how to use Fractal Noise to create fog.


Andy Ford
Adobe After Effects
Utimate Guide to Looping Footage and Compositions

Utimate Guide to Looping Footage and Compositions

Graham Quince, after spotting posts from those new to AE who don’t know about the options, has compiled the utlimate, time-saving, plug-and-play expressions that would take care of loop compositions for you.


Graham Quince
Adobe After Effects
Scars, Tattoos & Digital Makeup: After Effects & Mocha Pro

Scars, Tattoos & Digital Makeup: After Effects & Mocha Pro

How do you add SCARS, TATTOOS or DIGITAL MAKEUP to a person's face? Learn how to use Mocha Pro's planar tracker and the Mesh Warp tool to insert a flat image/video on a (non flat) human face! Join VFX guru Tobias G from Surfaced Studio for a closer look!


Tobias G
Adobe After Effects
Making a Tornado in After Effects using CC Particle World

Making a Tornado in After Effects using CC Particle World

Here's a quick tutorial showing how you can create a particle Twister in Adobe After Effects, using just the native plugins, mainly Cycore's CC Particle World with a bit of CC Vector Blur too.


Graham Quince
Adobe After Effects
After Effects: Changing a Rounded Corner's Radius

After Effects: Changing a Rounded Corner's Radius

Here's a really short, mythbusting tip. Recieved wisdom is that when drawing a rounded rectangle mask, once you let go, you can't change the radius. Turns out you can!


Graham Quince
Adobe After Effects
How to Keyframe a Wiggle in Adobe After Effects

How to Keyframe a Wiggle in Adobe After Effects

The Wiggle expression is really useful, but there are plenty of times when you want it to start, then fade down or vice versa.? This quick tutorial shows you a really simple way to control the Wiggle values using the Expression Controls effects.


Graham Quince
Adobe After Effects
Makin' Interstellar-style Black Hole using CC Particle World

Makin' Interstellar-style Black Hole using CC Particle World

Graham Quince shows how to use Adobe After Effects and CC Particle World to make an Interstellar Black Hole.

Tutorial
Graham Quince
Adobe After Effects
Makin' Starfields: Create presets for 2D, 360 and 3D stars

Makin' Starfields: Create presets for 2D, 360 and 3D stars

In this tutorial, I take a look at generating stars in Adobe After Effects. We start with a simple 2D starfield, but then use Fractal Noise to add atmospheric distortion (twinkling) and then I show how to save this effect as a preset, so it becomes really easy to reuse. Next, I take a look at wrapping those 2D stars around the inside of a Sphere to create a 360 starfield.


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