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

CC BY-SA 4.0
2018-05-10T14:15:11.270Z
How to do that with the position @stib ? Thank you very much!
Juri
CC BY-SA 4.0
2018-05-11T01:29:25.410Z
Exactly the same, that expression would work for position too
stib
CC BY-SA 3.0
2017-03-31T00:30:09.140Z
2017-03-31T00:30:09.140Z
stib
<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>

<after-effects><after-effects-expressions><after-effects-scripting>
Control key frame value with slider control
Delltar
# Control key frame value with slider control

(Asked by: username_0 on 2017-03-30)

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

**Tags:** after-effects, after-effects-expressions, after-effects-scripting


---

## 1 answers

### Answer by username_1 on 2017-03-31. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_2**: How to do that with the position @username_1 ? Thank you very much!  
> **username_1**: Exactly the same, that expression would work for position too  

---

