Just to continue this 11 year old thread, I am once again trying (without success) to use switch / case in an expression. The expression is to control a colour on a layer by a Slider control, so if I set the slider to 1, the colour is white, slider = 2 makes the colour dark blue and slider = 3 makes the colour orange.
Firstly, I tried this:
Choice = Math.floor(effect("Colour")("Slider").value);
switch( Choice ) {
case 1:
[255,255,255,0]
break;
case 2:
[20,27,77,0]
break;
case 3:
[249,56,34,0]
break;
default:
[249,56,34,0]
}
…then I converted it to a string to see if that helped:
Choice = "" + Math.floor(effect("Colour")("Slider").value);
switch( Choice ) {
case "1":
[255,255,255,0]
break;
case "2":
[20,27,77,0]
break;
case "3":
[249,56,34,0]
break;
default:
[249,56,34,0]
}
…then I just went with the ugly multiple if…then route:
Choice = "" + Math.floor(effect("Colour")("Slider"));
if ( Choice == "1"){ [255,25,255,0] } else
if ( Choice == "2"){ [20,27,77,0] } else
if ( Choice == "3"){ [249,56,34,0] } else {[255,0,0,0]};
…but none of them work at all! Any ideas, anyone?!
Thanks,
Paul
motion graphics | VFX | web design | etc.
https://paulroper.com/