After Effects Tutorial Add Zeros Before Counter Andy Ford

After Effects Tutorial – Add Zeros Before Counter

I’ve been asked many times about adding zeros in front of a number counter so that there are always a select number of digits appearing. A counter like this can be likened to a speedometer. This is done with expressions to pad your string.

Some contents or functionalities here are not available due to your cookie preferences!

This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

As usual, the initial expression from linking a text layer source text to a slider control will be:

num = effect(“Slider Control”)(“Slider”);

Then, set the length of the string. If you want 6 digits to always show, use the following for another variable:

X = 6 – num.toString().length;

Then, one more line of code is needed to return the proper value.  Basically, you will return the modified substring plus your original number that is controlled via slider control. The number of zeros in quotes varies depending on the number of digits you wish to return. Sticking with the 6-digit example, use the following:

“00000”.substr(0,x) + num;

Enjoying this tutorial? Sign up now for the Creative COW Newsletter!

Sign up for the Creative COW newsletter and get weekly updates on industry news, forum highlights, inspirational tutorials, tips, burning questions, and more! Receive bulletins from the largest, longest-running community dedicated to supporting professionals working in film, video, and audio.

Enter your email address, a first and last name, and let us know what you’d like to see more of in the message!

Responses

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy