ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Countdown using words and numbers

FAQ   •   VIEW ALL
 Countdown using words and numbers on Oct 20, 2018 at 4:04:09 pm

Hello

I'm trying to create a countdown that uses a mixture of numbers and words. For example, I'm starting a 300 and I want numbers from 300 down to 100. Then I want it to shift to using the numbers written out in word form. For example, ninety-nine, ninety-eight, etc. I've been using an expression I found here for the countdown. Here's the expression:

clockStart = 300;
clockTime = Math.max(clockStart - (time-inPoint),0);
sec = Math.floor(clockTime);
ms = clockTime.toFixed(2).substr(-2);
sec

Any suggestions? I'm definitely and beginner when it comes to this.

 Re: Countdown using words and numberson Oct 20, 2018 at 5:35:38 pm

Try this:

``` clockStart = 300; tens = ["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"]; ones = ["zero","one","two","three","four","five","six","seven","eight","nine"]; teens = ["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"]; clockTime = Math.max(clockStart - (time-inPoint),0); sec = Math.floor(clockTime); if (sec > 99){ sec; }else if (sec > 19){ tensDigit = Math.floor(sec/10); onesDigit = sec%10; tens[tensDigit] + (onesDigit > 0 ? " " + ones[onesDigit] : ""); }else if (sec > 9){ teens[sec-10]; }else{ ones[sec]; } ```

Dan

 Re: Countdown using words and numberson Oct 20, 2018 at 5:44:45 pm

Awesome! That worked!

Now my question is... what do I change so that I can modify when the words start and the numbers end? For example, let's say it should change from numbers to words at 33 seconds.

 Re: Countdown using words and numberson Oct 20, 2018 at 5:49:53 pm

For that case, you would change this line:

if (sec > 99){

to this:

if (sec > 33){

It gets more complicated if you want the change to happen at a number less than 20.

Dan

 Re: Countdown using words and numberson Oct 20, 2018 at 5:51:36 pm

Would it be easier to create a second countdown timer that starts at 20 and just uses words? or 10?