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

Using a slider controller to select specific values/numbers

New Here ,
Jun 25, 2019 Jun 25, 2019

Hi,

I'm having a bit of trouble figuring this one out. Hoping someone can help. I have a text layer with the animator "Character Value" being used. I'd like to attach a slider so that it toggles the character value to specific numbers. For example, using the slider, only these numbers "39, 45, 58, 61, 95, 96, 124, 168" will be appear or be input into the number field for "Character Value". Basically, with the slider, you can toggle and choose which value to use. I'd be very grateful if anyone can help. Thank you.

Francis

TOPICS
Expressions
5.7K
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

correct answers 1 Correct answer

Community Expert , Jun 25, 2019 Jun 25, 2019

Hi Francis,

I think I understand what you are trying to achieve and I have opted for a different solution. I've outlined what I did below but glossed over the why. If this doesn't work or you would like any of this explained further please let me know.

Michael

1. Create an Adjustment layer and add a Slider Control effect.

2. Create a text layer and input a single character.

3. To the text layer, from the Animate flyout menu add Character Value.

4. To the text layer, add an expression to the Character

...
Translate
Community Expert ,
Jun 25, 2019 Jun 25, 2019

Hi Francis,

I think I understand what you are trying to achieve and I have opted for a different solution. I've outlined what I did below but glossed over the why. If this doesn't work or you would like any of this explained further please let me know.

Michael

1. Create an Adjustment layer and add a Slider Control effect.

2. Create a text layer and input a single character.

3. To the text layer, from the Animate flyout menu add Character Value.

4. To the text layer, add an expression to the Character Value and paste the following code…

var theMatrix = [39,45,58,61,95,96,124,168];

var theSlider = thisComp.layer("Adjustment Layer 1").effect("Slider Control")("Slider");

var theMatrixPosition = Math.floor( (theSlider/100) * (theMatrix.length - 1) );

theMatrix[theMatrixPosition];

Dragging the Slider Control on the Adjustment layer will move through all of the values input into the variable called theMatrix. Be sure to keep the slider values between 0 and 100 (inclusive) or you will get an error.

capture.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 ,
Jun 25, 2019 Jun 25, 2019

That worked beautifully! Thank you.

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 ,
Jun 25, 2019 Jun 25, 2019

Hey fantastic. Happy to help.

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 Beginner ,
Jan 23, 2024 Jan 23, 2024

I'm trying to do this same thing, but as soon as I put the expression in, my text disappeared. The character value is correct in the properties, but it's invisible in the comp. Also, is there a way to do this where I can show numbers with decimals in them?

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 Beginner ,
Jan 23, 2024 Jan 23, 2024

I just noticed that when I tried the code with the original values, I didn't get numbers, I got characters like apostrophes, colons, and mathematical symbols. Not sure why.

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 ,
Jan 23, 2024 Jan 23, 2024

Numbers who are in the matrix array are Char Codes

 

 

var theMatrix = [39,45,58,61,95,96,124,168];

 

 

 

if you want to display numbers or whatever simply:

- create a text layer with a slider control

- add this expression to the Source Text property:

 

 

 

var array = [3.14, 45, "abc", 61, 95, 96, 124, 168];
var idx = clamp(Math.floor(effect("Slider Control")("Slider")), 0, array.length-1);

array[idx];

 

 

 

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 ,
Jan 23, 2024 Jan 23, 2024
LATEST

Michael, Don't use Adjustment Layers for Effects Controls like Slider Control or Dropdown Menu controls. Add your Expression Controls to Nulls or layers with pixels. Adjustment layers are only for Effects, and even if there is nothing on an adjustment layer, AE has to look at it and every pixel that is under it. 

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