user5928: 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


user1950: 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.


5928: <p>I have an object in After Effects comp and I need its scale to change from <em>keyframe A</em> to <em>keyframe B</em> and I need <em>keyframe A</em> to have value of 95% and <em>keyframe B</em> 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.</p>

<p>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.</p>

<pre><code>if (numKeys &gt; 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
</code></pre>
 1950: <p>You were close.</p>

<pre><code>if (numKeys &gt; 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
}
</code></pre>

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

<ul>
<li>On line 4 I assume you want it to be <code>95%</code> not <code>0</code>. I also changed it to an array.</li>
<li>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 <code>comp("INPUT" … (Slider)</code> 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.</li>
<li>on line 8 the <code>else</code> without curly braces works, but it makes me nervous.</li>
</ul>
