Copy link to clipboard
Copied
I'm trying to increase a number from 0 to 49.3 with slider control, but I need it to keep the decimal 0 on integers, and to add a leading 0 from 0 to 9. I've tried many expressions, and noticed that the leading number works if its anything but 0, for example, if I try to add "20" to the string on the condition < 10, it will add the 20, but it won't add the "0".
As for the integers decimal, I really couldn't make it work, even using expressions marked as 'solutions' on the forum. I wonder if the newer versions of AE changed something.
Anyone can help?
Thanks!
Copy link to clipboard
Copied
"0" + effect("Slider Control")(1)
// 9 => 09
// 20 => 020
isn't enough?
Copy link to clipboard
Copied
Not quite, I need it from 0 to 10 only - for which I can make an if statement, but still, the zero won't show up. If I put any other value, it will show before the numbers, but not the "0". Is that normal??
Thanks for trying!!
Copy link to clipboard
Copied
From 0 to 9:
val = effect("Slider Control")(1);
val < 10 ? "0" + val : val
Copy link to clipboard
Copied
Same problem! Works with anything else but "0"... I'm thinking of other ways of presenting the numbers...
Copy link to clipboard
Copied
It works with 0
Copy link to clipboard
Copied
Yeah, I know it should. I guess it's an issue with my AE...
Copy link to clipboard
Copied
Same result using padStart() ?
val = effect("Slider Control")(1);
[integerPart, decimalPart] = val.toString().split('.');
paddedInteger = integerPart.padStart(2, '0');
decimalPart ? `${paddedInteger}.${decimalPart}` : paddedInteger;
Copy link to clipboard
Copied
Yeah, same result... =(
Thanks for all the effort!
Copy link to clipboard
Copied
It might be helpful if you posted a screen shot showing the expression and the incorrect result.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now