Answers.Body: <p>Use a dropdown. Select <strong>Dropdown Expression Control</strong> from <strong>Effects&gt;Expression Controls</strong> and hit edit to input the colour names.</p>
  <p><a href="https://i.sstatic.net/MqFbm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MqFbm.png" alt="enter image description here" /></a></p>
  <p>Then use a <code>switch</code> to deal with the four possible choices.</p>
  <pre><code>let colourChoice = Math.round(thisComp.layer(&quot;White Solid 1&quot;).effect(&quot;Dropdown Menu Control&quot;)(&quot;Menu&quot;));
  switch (colourChoice){
      case 1 : [7, 250, 198, 255]/255.0;
          break;
      case 2 : [252, 12, 119, 255]/255.0;
          break;
      case 3 : [0, 0, 0, 0];
          break;
      default:  [1, 1, 1, 1];
  </code></pre>
  <p>}</p>
  <p><strong>N.B.:</strong></p>
  <ul>
  <li><p><code>Math.round</code> on the firstline is to convert the numeric result returned from the dropdown to an integer, I'm not sure what kind of numerical value is returned from a dropdown, but just using <code>let colourChoice = thisComp.layer(&quot;White Solid 1&quot;).effect(&quot;Dropdown Menu Control&quot;)(&quot;Menu&quot;)</code> doesn't work.</p>
  </li>
  <li><p>Colours in expressions are four-dimensional RGBA arrays, because even if they don't use alpha they need a value for alpha.</p>
  </li>
  <li><p>And finally the <code>/ 255</code> after the array is to convert the 0-255 RGBA values into 0-1.0 floating point values for colour. You could do the maths beforehand, but it's more legible like this.</p>
  </li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-26T13:48:39.263Z
Answers.Text: I've been using AE 2019 but I see now the great advantage of 2020.
  I've tried it but whatever I do it keeps saying `Error: Expected: ;`
Answers.UserDisplayName: Apeiron_Sound
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-26T23:23:07.527Z
Answers.Text: 2019 uses a different expression language. Instead of `switch` you'll have to use `if(colourChoice === 1){…} else if (colourChoice === 2){…` And use `var` instead of `let`
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-27T10:36:38.950Z
Answers.Text: 2019 doesn't support Dropdown Menu, so I've tried on 2020 but that's where it shows that `;` problem.
Answers.UserDisplayName: Apeiron_Sound
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-26T06:14:49.597Z
Answers.LastActivityDate: 2021-01-26T06:23:23.710Z
Answers.LastEditDate: 2021-01-26T06:23:23.710Z
Answers.UserDisplayName: stib
Body: <p>I'm trying to create an <strong>Essential Graphic</strong> that allows the user to change a layer's colour into <em>4 specific ones</em>:</p>
  <p><em>Teal: 7, 250, 198<br />
  Pink: 252, 12, 119<br />
  Black: 0, 0, 0<br />
  White: 255, 255, 255</em></p>
  <ul>
  <li><em>Colour Control</em> isn't an option as it gives too much freedom.</li>
  <li><em>Checkbox Control</em> isn't either as it is not a 2 colours boolean/switch.</li>
  </ul>
  <p>A Slider Control I think would be a good option but I need something similar to the <em>clamp expression</em> to keep the slider in control, something that would make my slider move in ones or specific steps.</p>
  <p>Maybe I'm completely off track, I'm open to better solutions!</p>
  
Tags: <video><after-effects><animation><adobe><after-effects-expressions>
Title: AE Controller for changing layer into specific colours
UserDisplayName: Apeiron_Sound
ThreadText: # AE Controller for changing layer into specific colours
  
  (Asked by: username_0 on 2021-01-21)
  
  I'm trying to create an **Essential Graphic** that allows the user to change a layer's colour into *4 specific ones*:
  
  *Teal: 7, 250, 198  
  Pink: 252, 12, 119  
  Black: 0, 0, 0  
  White: 255, 255, 255*
  
  * *Colour Control* isn't an option as it gives too much freedom.
  * *Checkbox Control* isn't either as it is not a 2 colours boolean/switch.
  
  A Slider Control I think would be a good option but I need something similar to the *clamp expression* to keep the slider in control, something that would make my slider move in ones or specific steps.
  
  Maybe I'm completely off track, I'm open to better solutions!
  
  **Tags:** video, after-effects, animation, adobe, after-effects-expressions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-01-26. Score: 1
  
  Use a dropdown. Select **Dropdown Expression Control** from **Effects>Expression Controls** and hit edit to input the colour names.
  
  [![enter image description here](https://i.sstatic.net/MqFbm.png)](https://i.sstatic.net/MqFbm.png)
  
  Then use a `switch` to deal with the four possible choices.
  
  ```
  let colourChoice = Math.round(thisComp.layer("White Solid 1").effect("Dropdown Menu Control")("Menu"));
  switch (colourChoice){
      case 1 : [7, 250, 198, 255]/255.0;
          break;
      case 2 : [252, 12, 119, 255]/255.0;
          break;
      case 3 : [0, 0, 0, 0];
          break;
      default:  [1, 1, 1, 1];
  
  ```
  
  }
  
  **N.B.:**
  
  * `Math.round` on the firstline is to convert the numeric result returned from the dropdown to an integer, I'm not sure what kind of numerical value is returned from a dropdown, but just using `let colourChoice = thisComp.layer("White Solid 1").effect("Dropdown Menu Control")("Menu")` doesn't work.
  * Colours in expressions are four-dimensional RGBA arrays, because even if they don't use alpha they need a value for alpha.
  * And finally the `/ 255` after the array is to convert the 0-255 RGBA values into 0-1.0 floating point values for colour. You could do the maths beforehand, but it's more legible like this.
  
  > **Comments:**
  > **username_0**: I've been using AE 2019 but I see now the great advantage of 2020. I've tried it but whatever I do it keeps saying `Error: Expected: ;`  
  > **username_1**: 2019 uses a different expression language. Instead of `switch` you'll have to use `if(colourChoice === 1){…} else if (colourChoice === 2){…` And use `var` instead of `let`  
  > **username_0**: 2019 doesn't support Dropdown Menu, so I've tried on 2020 but that's where it shows that `;` problem.  
  
  ---
  
  