Skip to main content
Participant
September 11, 2018
Answered

Link slider with 1 keyframe to adjust the Y value while maintaining X value

  • September 11, 2018
  • 1 reply
  • 3149 views

Dear Creative Guru's,

I am looking for an expression that would let me scale the y axis of only the last of 2 keyframes using a slider while maintaining a fixed X value. So for example:

Keyframe 1: [300,0]   Keyframe 2: [300,whatever the slider value is]

I can't seem to figure it out. So any help would be much appreciated.

Kind regards,

Robin

    This topic has been closed for replies.
    Correct answer Roland Kahlenberg

    This works but don't forget to apply a Slider Expression Control to the same layer and name it Y Scale Offset (last KF).

    ------------------------------------

    scalarVal = effect("Y Scale Offset (last KF)")("Slider");

    targetProp = transform.scale;

    lastKey = targetProp.numKeys;

    lastKeyTime = targetProp.key(lastKey).time;

    linear(time,key(1).time,lastKeyTime,[value[0],value[1]],[value[0],value[1]+scalarVal])

    ------------------------------------

    1 reply

    Community Expert
    September 11, 2018

    Scale values are in an array like this: [50, 100]

    That translates to x at 50% and y at 100%.

    You can pull the existing value from a keyframe using the value method. This is how you would tell an expression to look at the existing value for x and give the Y value 75%.  [value[0], 75];

    A slider only has one set of values. You can extract the value of a slider easily by just using the pickwhip to attach a variable to the slider by simply typing y = and then dragging the pickwhip to the expression slider and closing the line of code with a ;  If the slider is attached to the same layer you get something like this:
    y = effect("Slider Control")("Slider");

    You can also so simple math using  +, -, *, and /

    If you want the slider to modify the existing y keyframes then you would write your expression like this:

    y = effect("Slider Control")("Slider");

    [value[0], value[1] + y]

    If you wanted to control the Y value directly with the slider and ignore any existing values for y the expression would be simply:

    y = effect("Slider Control")("Slider");

    [value[0], y]

    That should get you started. The Search Help field in the top right corner of AE will point you in the right direction if you simply type expression slider and press enter. It's pretty easy to figure out basic expression language.

    Participant
    September 12, 2018

    Rick,

    Thank you for your detailed explanation about the subject. This will get me very close to my end goal. However is there any way to make the expression below only effect the last keyframe out of 2 keyframes.

    y = effect("Slider Control")("Slider");

    [value[0], y]

    this is roughly what I am looking for: Keyframe 1: [300, always 0]   Keyframe 2: [300,whatever the slider value is]

    looking forward to your reply,

    Robin

    Roland Kahlenberg
    Roland KahlenbergCorrect answer
    Legend
    September 12, 2018

    This works but don't forget to apply a Slider Expression Control to the same layer and name it Y Scale Offset (last KF).

    ------------------------------------

    scalarVal = effect("Y Scale Offset (last KF)")("Slider");

    targetProp = transform.scale;

    lastKey = targetProp.numKeys;

    lastKeyTime = targetProp.key(lastKey).time;

    linear(time,key(1).time,lastKeyTime,[value[0],value[1]],[value[0],value[1]+scalarVal])

    ------------------------------------

    Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV