<p>Here's a way to do it</p>
<p>Put a slider on your middle layer
Add the following expression to the middle layer's position control:</p>
<pre><code>xval = transform.position[0];
yval = transform.position[1];
x = xval + effect(&quot;Slider Control&quot;)(&quot;Slider&quot;);
y = yval + effect(&quot;Slider Control&quot;)(&quot;Slider&quot;);
[x,y]
</code></pre>
<p>Then put this on your bottom layer's position control:</p>
<pre><code>xval = transform.position[0];
yval = transform.position[1];
x = xval + thisComp.layer(&quot;middle&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;)*2;
y = yval + thisComp.layer(&quot;middle&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;)*2;
[x,y]
</code></pre>
<p>Then animate the slider value.</p>
<p>This adjusts the x and y position of the middle image by the amount on the slider. And doubles that amount for the bottom image.</p>
<p><a href="https://i.sstatic.net/8x95u.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8x95u.gif" alt="screengrab" /></a></p>

CC BY-SA 4.0
2021-11-14T09:08:22.560Z
Thank you tomh.. I'll be using multiple chat windows for the animation and maybe use the pick whip tool to link the chat windows.. but I'm still quite new to expressions and I'm not quite sure what the code below is for:

xval = transform.position[0];
yval = transform.position[1];
[x,y]

does this control the direction where the object moves? I've tried changing the value for transform.position but it displaces the object and no longer at the center. Thank you for the help though
Deviruchi D Devourer
CC BY-SA 4.0
2021-11-14T09:27:25.787Z
The Xval and yval things are just to keep your original position values (there might be a better way to do this, not sure). There’s a good tutorial for beginning expressions here: https://www.schoolofmotion.com/blog/six-essential-expressions-creative-coding-after-effects
tomh
CC BY-SA 4.0
2021-11-14T09:59:04.413Z
Thanks for the help.. I'll do some experimentation and see if I can achieve what I want.. thanks again, this helped me a lot
Deviruchi D Devourer
CC BY-SA 4.0
2021-11-14T10:36:03.130Z
If you have lots of layers to animate, you may want to use the index command to control the multiplier, instead of manually changing the multiplying value in each layer. See this tutorial for info: https://www.rocketstock.com/blog/using-the-index-expression-in-after-effects/
tomh
CC BY-SA 4.0
2021-11-14T07:58:47.020Z
2021-11-14T07:58:47.020Z
tomh
<p>I'm kinda new to After Effects and I'm having a hard time creating a slider that I can control to move the chat windows with the same distance. The chat windows will start at the center and only one would show up. When I move the slider, it will show up the remaining 6 chat windows. I wanted for them to have the same distance and have the flexibility to use the slider. Here's an image of what the chat windows would look like if I move the slider.<a href="https://i.sstatic.net/VebKX.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/VebKX.jpg" alt="multi chat window" /></a></p>

<after-effects><motion-graphics>
After Effects creating slider for objects to have the same distance when moving the slider
Deviruchi D Devourer
# After Effects creating slider for objects to have the same distance when moving the slider

(Asked by: username_0 on 2021-11-12)

I'm kinda new to After Effects and I'm having a hard time creating a slider that I can control to move the chat windows with the same distance. The chat windows will start at the center and only one would show up. When I move the slider, it will show up the remaining 6 chat windows. I wanted for them to have the same distance and have the flexibility to use the slider. Here's an image of what the chat windows would look like if I move the slider.[![multi chat window](https://i.sstatic.net/VebKX.jpg)](https://i.sstatic.net/VebKX.jpg)

**Tags:** after-effects, motion-graphics


---

## 1 answers

### Answer by username_1 on 2021-11-14. Score: 0

Here's a way to do it
Put a slider on your middle layer
Add the following expression to the middle layer's position control:
xval = transform.position[0];
yval = transform.position[1];
x = xval + effect("Slider Control")("Slider");
y = yval + effect("Slider Control")("Slider");
[x,y]

Then put this on your bottom layer's position control:
xval = transform.position[0];
yval = transform.position[1];
x = xval + thisComp.layer("middle").effect("Slider Control")("Slider")*2;
y = yval + thisComp.layer("middle").effect("Slider Control")("Slider")*2;
[x,y]

Then animate the slider value.
This adjusts the x and y position of the middle image by the amount on the slider. And doubles that amount for the bottom image.

> **Comments:**
> **username_0**: Thank you username_1.. I'll be using multiple chat windows for the animation and maybe use the pick whip tool to link the chat windows.. but I'm still quite new to expressions and I'm not quite sure what the code below is for:  xval = transform.position[0]; yval = transform.position[1]; [x,y]  does this control the direction where the object moves? I've tried changing the value for transform.position but it displaces the object and no longer at the center. Thank you for the help though  
> **username_1**: The Xval and yval things are just to keep your original position values (there might be a better way to do this, not sure). There’s a good tutorial for beginning expressions here: https://www.schoolofmotion.com/blog/six-essential-expressions-creative-coding-after-effects  
> **username_0**: Thanks for the help.. I'll do some experimentation and see if I can achieve what I want.. thanks again, this helped me a lot  
> **username_1**: If you have lots of layers to animate, you may want to use the index command to control the multiplier, instead of manually changing the multiplying value in each layer. See this tutorial for info: https://www.rocketstock.com/blog/using-the-index-expression-in-after-effects/  

---

