Express Yourself With Numbers! An After Effects Tutorial
COW Library : Adobe After Effects Tutorials : Andy Ford : Express Yourself With Numbers! An After Effects Tutorial
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 Altclick (Optionclick 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 inbetween 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(); 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(); 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 •
•
•
