Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Animated number with leading zeros and decimal places

  • Animated number with leading zeros and decimal places

    Posted by Scott Green on July 15, 2020 at 2:01 pm

    I’m trying to animate a number, linked to a Slider Control, which has leading zeros and decimal places.

    This code works quite well for the leading zeros part which I found here…
    https://graphicdesign.stackexchange.com/questions/64477/after-effects-custom-counter-expression

    val = Math.round(thisLayer.effect("Slider Control")("Slider"));
    ('0000' + val).slice(-4)

    But I’m struggling to figure out how to include decimal places.
    In normal cases I’d use this code to change the number of decimal places that I’d like to have displayed but it doesn’t seem to work with this expression.
    [0].toFixed(2)

    Does anyone have a solution please?

    Thank you.

    Motion Videos UK – We are creative video designers who bring pleasure, meaning and beauty to our small world through film, motion graphics and animation.

    Scott Green replied 5 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    July 15, 2020 at 2:58 pm

    This should work:

    (“0000″+effect(“Slider Control”)(“Slider”).value.toFixed(2)).slice(-7)

    just make the negative slice value 3 more (4 + the point + two decimals = 7)

  • Scott Green

    July 16, 2020 at 9:51 am

    Works perfectly, thank you.

    Motion Videos UK – We are creative video designers who bring pleasure, meaning and beauty to our small world through film, motion graphics and animation.

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