Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-14T09:08:22.560Z
Answers.Text: 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
Answers.UserDisplayName: Deviruchi D Devourer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-14T09:27:25.787Z
Answers.Text: 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
Answers.UserDisplayName: tomh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-14T09:59:04.413Z
Answers.Text: 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
Answers.UserDisplayName: Deviruchi D Devourer
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-14T10:36:03.130Z
Answers.Text: 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/
Answers.UserDisplayName: tomh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-14T07:58:47.020Z
Answers.LastActivityDate: 2021-11-14T07:58:47.020Z
Answers.UserDisplayName: tomh
Body: <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>
  
Tags: <after-effects><motion-graphics>
Title: After Effects creating slider for objects to have the same distance when moving the slider
UserDisplayName: Deviruchi D Devourer
ThreadText: # 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.
  
  [![screengrab](https://i.sstatic.net/8x95u.gif)](https://i.sstatic.net/8x95u.gif)
  
  > **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/  
  
  ---
  
  