ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Slider Value Expression Linked to Single Keyframe

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sam Caino
Slider Value Expression Linked to Single Keyframe
on Jun 2, 2017 at 2:18:43 am

Hi Folks,

I want to control a slider value with a number in a text layer. The below expression works in my composition. However, I want to keyframe it so the first keyframe is zero and the second keyframe corresponds to the value set by the text layer in the expression ("Number").

Is there any way to modify this expression so it only attaches to the second keyframe, leaving my first keyframe value set to zero?

txt=thisComp.layer("Number").text.sourceText;
if (! isNaN(parseFloat(txt)))
parseFloat(txt)
else
value




Return to posts index

Dan Ebberts
Re: Slider Value Expression Linked to Single Keyframe
on Jun 2, 2017 at 1:03:14 pm

If they are linear keyframes, and there are only two of them, something like this should work:


txt=thisComp.layer("Number").text.sourceText;
val = parseFloat(txt);
if (numKeys > 1 && (! isNaN(val)))
linear(time,key(1).time,key(2).time,key(1).value,val)
else
value



Dan



Return to posts index

Otto Tasnadi
Re: Slider Value Expression Linked to Single Keyframe
on Nov 22, 2019 at 12:47:06 pm

Hey, I want to use the same expression but I want the numbers to be rounded. Can you give me some tips on this? thanks!


Return to posts index


Dan Ebberts
Re: Slider Value Expression Linked to Single Keyframe
on Nov 22, 2019 at 5:25:24 pm

Like this maybe:


txt=thisComp.layer("Number").text.sourceText;
val = parseFloat(txt);
if (numKeys > 1 && (! isNaN(val)))
v = linear(time,key(1).time,key(2).time,key(1).value,val)
else
v = value;
Math.round(v)



Dan



Return to posts index

Otto Tasnadi
Re: Slider Value Expression Linked to Single Keyframe
on Nov 25, 2019 at 1:20:13 pm

Thanks a lot!


Return to posts index

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