Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Again with the counting down…

  • Again with the counting down…

    Posted by Brian Smith on April 24, 2007 at 7:53 am

    Hey hey AE masters–
    First off I have to thank you soo much, you’ve helped guide me through virtually everything I’ve needed to know.
    This is the first time I’ve had to post, nonetheless…

    here it is-
    I just want to make a simple countdown from 50 to 00. I think I’m over-complicating it, but expressions simply aren’t my dig yet.

    this is what I have in the “source text” property-
    Math.ceil(50-(time*15));
    i know that by writing it this way, everything is being based off my timeline, so if there’s another way I’m overlooking that would solve the problem below ?

    here’s the problem-
    it counts into negative numbers. so I have to give it an if/else property and I can’t seem to get it to where I want. The expression above counts at the correct speed for me, I just can’t get it to stop.

    Any suggestions?!! Please help!

    Thanks-
    BS

    ———-
    Brian Smith
    http://www.renderedhero.com
    PDX, ORYGUN

    Brian Smith replied 19 years ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    April 24, 2007 at 11:11 am

    Hi Hero, there are different ways to approach this:
    something like this:

    t=Math.ceil(50-(time*15));
    if (t>0) {
    t
    } else {
    0
    }

    there’s a shorthand version of if/then/else too:

    t=Math.ceil(50-(time*15));
    t>0 ? t : 0 ;

    or with a Math.max() function:

    Math.max(Math.ceil(50-(time*15)) , 0);

    (returns whichever of two numbers is the highest: your calculation or zero: this eliminates negative numbers.

    or (the most versatile and simplest) use linear()

    Math.ceil(linear(time, 0, 50/15, 50, 0)):

    meaning this:
    for time (parameter 1)
    if time=0 (2nd parameter), return 50 (4th parameter).
    if time=50/15 (3rd parameter), return 0 (5th parameter).
    for every time-value inbetween do a linear interpolation.

    Powerful stuff once you get your head around it.

  • Brian Smith

    April 25, 2007 at 6:21 am

    Filip – It worked like a charm! Thanks so much!!

    ———-
    Brian Smith
    http://www.renderedhero.com
    PDX, ORYGUN

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