Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expressions that count

  • Expressions that count

    Posted by Stu Pond on November 23, 2009 at 2:51 pm

    I have a job where I need to count between various integers both whole and with decimal places that start all over the place i.e. 135 – 166 or 4.2 – 8.3 etc.. As I suspect I might have to retime these quickly I was wondering if there was an expression that would enable me to do this, perhaps over the length of a layer or using a defined start and finish time within the comp?

    Stu Pond replied 16 years, 5 months ago 3 Members · 5 Replies
  • 5 Replies
  • Andy Dykstra

    November 24, 2009 at 3:00 am

    The easiest way is probably to add a slider control to your text layer. Add a keyframe with the starting number as the value, and another keyframe with the ending value. Then it’s as simple as adding an expression to the text layer’s source text that links it to the value of the slider. As the slider value shifts from the start value to the end value, your text layer will display the value.
    If you need whole numbers, just add “Math.floor(” before the expression, and be sure to close the parentheses. This will round the number down.

  • Stu Pond

    November 24, 2009 at 11:31 am

    That’s brilliant, thanks. Is it possible to specify the number of decimal places?

    Once again – thanks!

  • Andy Dykstra

    November 25, 2009 at 4:28 pm

    I think this should work – inside the parentheses for the Math.floor() portion take your value times 10, 100, 1000, one 0 for each decimal place, then divide the whole thing by the same number.

    Math.floor(effect("Slider Control")("Slider")*1000) / 1000

    http://www.ghostrender.com

  • Ryan Hill

    November 25, 2009 at 7:52 pm

    I think you can also use .toFixed()

  • Stu Pond

    November 27, 2009 at 10:20 am

    Thanks very much for that – you’ve saved me bags of time on this job. Much respect 🙂

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