ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Combining Slider value with text variable, is this possible?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Billy Sides
Combining Slider value with text variable, is this possible?
on Mar 6, 2013 at 7:52:00 pm

I have a slider that I want to drive a file name ie.
myComp_+SLIDER VALUE+_link

end result would be something like this:
myComp_1_link
myComp_2_link
myComp_3_link

I keep getting this error:
Invalid Numeric Result (divide by zero?)

I think it's due to the fact I'm trying to combine a number with a text string.

Any ideas how to combine the two?

Thanks,

-bsides


Return to posts index

Dan Ebberts
Re: Combining Slider value with text variable, is this possible?
on Mar 6, 2013 at 9:38:05 pm

Probably more like this:

myComp.name + "_" + Math.round(mySliderVal) + "_link";


Dan



Return to posts index

Billy Sides
Re: Combining Slider value with text variable, is this possible?
on Mar 6, 2013 at 10:23:45 pm

Thanks Dan, that worked just fine. Weird that you have to round the number to add it to a string...

Thanks again,

-bsides


Return to posts index


Dan Ebberts
Re: Combining Slider value with text variable, is this possible?
on Mar 6, 2013 at 10:34:18 pm

You don't have to round it, but you don't want to end up with 0.99999999999997 instead of 1. I'd do it just to make sure you end up with an integer.

Dan



Return to posts index

Jeff Bobbington
Re: Combining Slider value with text variable, is this possible?
on May 13, 2014 at 2:10:40 pm

Is it possible to have a text layer read out a number from a slider without rounding it up?
My text layer has a slider(Time), the source text expression is this:

t = effect("Time")("Slider");

'Timer: '+t



In my mind, this should simply make the text read 'Timer: 53.46', but instead it tells me that it's an invalid numerical result. Annoyingly, it works fine if I apply Math.round to the time expression.


Return to posts index

Dan Ebberts
Re: Combining Slider value with text variable, is this possible?
on May 13, 2014 at 2:13:19 pm

Try it this way:

t = effect("Time")("Slider").value;
'Timer: '+t


Dan



Return to posts index


Jeff Bobbington
Re: Combining Slider value with text variable, is this possible?
on May 13, 2014 at 2:54:15 pm

That worked, I already tried it actaully, but I guess my text box was cutting off the value so I assumed it didn't. Derp!

Thanks Sir


Return to posts index

Gabriel Ferrão
Re: Combining Slider value with text variable, is this possible?
on Sep 11, 2014 at 6:43:09 pm

Hi there,

Is it possible to change the value within "" with a slider?

I've got a layer that has three effects (Red Giant's Sound Keys). Inside each of these effects, there are three values that are of interest to me.

I'd like to write an expression (using sliders), where I can toggle between the three different effects, and within that, toggle between those three different values.

Here is the string I'm trying to alter:

thisComp.layer("SOUNDKEYS").effect("Sound Keys 3")("Output 1")

I was hoping that I could select the number 3, for example, and pick-whip that to a slider, but it didn't work.
Then I decided to use what someone suggested earlier and do something like

S=effect("SOUNDKEYS #")("Slider");
thisComp.layer("SOUNDKEYS").effect("Sound Keys S")("Output 1")

But the result is that "Sound Keys S" is missing or does not exist.

Hope that makes sense...
I'm trying to avoid going into the expression and manually changing the numeric values, since I'd have to do that countless times.
Thanks!


Return to posts index

Dan Ebberts
Re: Combining Slider value with text variable, is this possible?
on Sep 11, 2014 at 6:59:28 pm

That would be something like this:

n = Math.round(effect("Slider Control")("Slider"));
thisComp.layer("SOUNDKEYS").effect("Sound Keys " + n)("Output 1")


Dan



Return to posts index


Thomas Frenkel
Re: Combining Slider value with text variable, is this possible?
on Dec 15, 2016 at 10:05:12 am

Sorry for digging out this out thread, but I need some help in a quite similar case:

I have a slider control with values between 1000 and 300000 that I linked to the sourceText. I want to add a dot to have the numbers display like this:

1.000,
300.000,
etc

I want to keep the luxury of just animating the slider to change the current value. So my guess was to use "length" to get the total amount of characters and work with "substring" for the part before the dot and the part after the dot:

val=Math.round(SLIDER); //value like "300000"
amountChars=val.length; //amount of characters
sString=amountChars-3; //dot is right before the last 3 chars
val.substr(0,sString); // the first part of the value before the dot

The problem is, that substring won't recognize the slider values as a string (unlike the sourceText parameter);
It works when I use normal text, but not when I input the slider values.

Would appreciate some help


Return to posts index

Thomas Frenkel
Re: Combining Slider value with text variable, is this possible?
on Dec 15, 2016 at 10:24:07 am

Ah, I found a workaround:

I am working with 2 text layers now:

One uses the slider for the sourceText, which will convert the slider values to a string. This layer is just for the conversion and is not displayed.

The second text layer will use the converted sourceText of the first layer by just linking it. Then I did the following expression to get the dot:

val=thisComp.layer("INPUT").text.sourceText;
amtC=val.length;
sString=amtC-3;
sString2=3;
val.substr(0,sString)+"."+val.substr(sString,amtC);


Return to posts index

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