Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Countdown using words and numbers

  • Countdown using words and numbers

    Posted by Geoff Mclarty on October 20, 2018 at 4:04 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.

    Dan Ebberts
    replied 7 years, 6 months ago
    2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    October 20, 2018 at 5:35 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

  • Geoff Mclarty

    October 20, 2018 at 5:44 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.

  • Dan Ebberts

    October 20, 2018 at 5:49 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

  • Geoff Mclarty

    October 20, 2018 at 5:51 pm

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

  • Dan Ebberts

    October 20, 2018 at 6:15 pm

    Probably.

    Dan

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