Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Leading zero and decimal in slider control

New Here ,
Nov 05, 2024 Nov 05, 2024

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! 

TOPICS
Expressions , How to
819
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 05, 2024 Nov 05, 2024
"0" + effect("Slider Control")(1)

// 9 => 09
// 20 => 020

isn't enough?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2024 Nov 05, 2024

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!! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 05, 2024 Nov 05, 2024

From 0 to 9:

val = effect("Slider Control")(1);
val < 10 ? "0" + val : val

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2024 Nov 05, 2024

Same problem! Works with anything else but "0"... I'm thinking of other ways of presenting the numbers... 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 05, 2024 Nov 05, 2024

It works with 0

screenshot.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2024 Nov 05, 2024

Yeah, I know it should. I guess it's an issue with my AE... 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 05, 2024 Nov 05, 2024

Same result using padStart() ?

 

val = effect("Slider Control")(1);
[integerPart, decimalPart] = val.toString().split('.');
paddedInteger = integerPart.padStart(2, '0');
decimalPart ? `${paddedInteger}.${decimalPart}` : paddedInteger;

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2024 Nov 05, 2024

Yeah, same result... =( 

Thanks for all the effort!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 05, 2024 Nov 05, 2024
LATEST

It might be helpful if you posted a screen shot showing the expression and the incorrect result.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines