ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Animated number with leading zeros and decimal places

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott Green
Animated number with leading zeros and decimal places
on Jul 15, 2020 at 2:01:43 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-custo...

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.


Return to posts index

Filip Vandueren
Re: Animated number with leading zeros and decimal places
on Jul 15, 2020 at 2:58:28 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)



Return to posts index

Scott Green
Re: Animated number with leading zeros and decimal places
on Jul 16, 2020 at 9:51:59 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]