1

I have an object in After Effects comp and I need its scale to change from keyframe A to keyframe B and I need keyframe A to have value of 95% and keyframe B value of whatever is set via slider control. Now I know how to set overall scale by slider, but I seem to have problem finding a way to link just that one keyframe to my slider control.

I am fairly new to expressions and I tried to re-purpose following one I found for the same thing but with opacity, but it doesn't work. I think it's because it supplies just one value and scale needs two values, but I honestly have very little idea whats going on in the expression and how to adapt it.

if (numKeys > 1){
  t1 = key(1).time;
  t2 = key(2).time;
  v1 = 0;
  v2 = comp("INPUT").layer("CONTROL").effect("Zoom intensity")("Slider");
  linear(time,t1,t2,v1,v2);
}else
  value
2

You were close.

if (numKeys > 1){
  t1 = key(1).time;
  t2 = key(2).time;
  v1 = [95, 95]; //or if it's 3d [95, 95, 95]
  slider = comp("INPUT").layer("CONTROL").effect("Zoom intensity")("Slider");
  v2 = [slider, slider]; // or [slider,slider,slider] if 3D
  linear((time, t1, t2, v1, v2);
} else {
  value
}

You were right that the scale property requires 2 (or 3) dimensions. So you need to use arrays, which look like [value1, value2], or [value1, value2, value3,… valueN] for as many members you want the array to have.

  • On line 4 I assume you want it to be 95% not 0. I also changed it to an array.
  • on line 5 I assign the slider value to a temporary variable and then put that in an array. You could do it in one line by repeating the comp("INPUT" … (Slider) phrase inside an array, but it would be really long and awkward. Alternatively you could use a point control if you wanted to be able to set the dimensions separately.
  • on line 8 the else without curly braces works, but it makes me nervous.
  • How to do that with the position @stib ? Thank you very much! – Juri May 10 '18 at 14:15
  • Exactly the same, that expression would work for position too – stib May 11 '18 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.