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.

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 six 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;

Please watch this short tutorial video: