Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Precise Number 10 Second Countdown

  • Precise Number 10 Second Countdown

    Posted by Lisa Ruiz on September 14, 2009 at 11:12 pm

    I know there are plenty of countdown posts, but I couldn’t find this exact problem.

    I need to create a number countdown for an academy leader. It needs to be 10 seconds long and count down from 10 to 1.

    Here’s my problem, so far the scripts I’ve tried and the “numbers” effect have not created an exact 10 second countdown. I can get it to start with 10 and end on 1 but, I need each number to stay on for 1 second each.

    I saw a comment somewhere that said to use: math.ceil for a precise count, but I couldn’t figure it out. I also tried taking a money count script and altering it, but again it is not precise.

    Any clues?

    numDecimals = 0;
    commas = true;
    dollarSign = 0;
    beginCount = 10;
    endCount = 1;
    dur = 10;

    t = time - inPoint;
    s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals);

    prefix = "";
    if (s[0] == "-"){
    prefix = "-";
    s = s.substr(1);
    }
    if(dollarSign) prefix += "$";

    if (commas){
    decimals = "";
    if (numDecimals > 0){
    decimals = s.substr(-(numDecimals + 1));
    s = s.substr(0,s.length - (numDecimals + 1));
    }
    outStr = s.substr(-s.length, (s.length-1)%3 +1);
    for (i = Math.floor((s.length-1)/3); i > 0; i--){
    outStr += "," + s.substr(-i*3,3);
    }
    prefix + outStr + decimals;
    }else{
    prefix + s;
    }

    Lisa Ruiz replied 16 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 14, 2009 at 11:26 pm

    Try this:

    10 – Math.floor(time)

    Dan

  • Lisa Ruiz

    September 15, 2009 at 4:17 pm

    Awesome, works like a charm. Don’t know why I couldn’t figure it out before. Thank you very much.

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