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

Help with Expression for Adding a Prefix Number to a Slider Control Range Attached to Source Text

Community Beginner ,
Apr 21, 2022 Apr 21, 2022

Copy link to clipboard

Copied

I'm trying to animate a 7 digit number counting up sequentially from 1000000 to 1987654 and am using an expression control slider attached to a Source Text element. The problem I'm trying to solve is that the "edit range" values on the slider control max out at the starting point value (1000000), so I'm trying to figure out how to add an expression that can place a prefix of "1" at the begining of the number sequence and use the slider control to count up using only a 6-digit range instead. (i.e. 100000 to 987654). Can anyone help with how to use an expression to add that single digit "1" at the begining of the Source Text element or slider control?

TOPICS
Expressions , How to

Views

118

Likes

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Apr 21, 2022 Apr 21, 2022

You could set keyframes on your slider for 0 and 987654 and then use a source text exrpession like this:

1000000 + Math.round(effect("Slider Control")("Slider"))

 

Likes

Translate

Translate
Community Expert ,
Apr 21, 2022 Apr 21, 2022

Copy link to clipboard

Copied

You could set keyframes on your slider for 0 and 987654 and then use a source text exrpession like this:

1000000 + Math.round(effect("Slider Control")("Slider"))

 

Likes

Translate

Translate

Report

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 Beginner ,
Apr 21, 2022 Apr 21, 2022

Copy link to clipboard

Copied

Thanks. I am already using the round expression to remove the decimal points, but the problem I'm trying to solve it that the slider control range maxes out at my starting point (.i.e 1000000) and I need to count up from there to 1987654. The only way that I can do that, is to set a 6-digit range and (hopefully) just hard code a prefix "1" at the begining that always remains static in order to end up with a 7-digit sequence. I'm looking for how to write an expression that adds a single digit "1" at the start of the source text.

Likes

Translate

Translate

Report

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 ,
Apr 21, 2022 Apr 21, 2022

Copy link to clipboard

Copied

This would be another way:

n = Math.round(effect("Slider Control")("Slider"));
"1" + String(n).padStart(6,0);

Likes

Translate

Translate

Report

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 ,
Apr 21, 2022 Apr 21, 2022

Copy link to clipboard

Copied

LATEST

You have 32000 discrete values on a slider and that's it. A direct approach will never work therefore. Even if you were to hard-code the leading 1 into the string, you still don't have enough numbers to count up to your value. therefore the motto of the day has to be to actually scale the values, i.e. multiply decimal values with a fixed number. Going from 1000000 to 9999999 therefore could be as trivial as slider*1000 and setting the start and end values to 1000 and 9999.9999, respectively.

 

Mylenium

Likes

Translate

Translate

Report

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