Hi. I have a bunch of layers with the "circle"-effect applied on it. I have a "control"-layer with 4 defined colors. The aim is:
Layer1: color1
Layer2: color2
Layer3: color3
Layer4: color4
Layer5: color1
Layer6: color2
...(and so on)
This is my lousy try, but it doesn't work:
(applied on the color option of the circle effect)
var a = ('1','5',...);
var b = ('2','6',...);
var c = ('3','7',...);
var d = ('4','8',...);
if (thisLayer.index=a){
thisComp.layer("control").effect("color1")("color")
}
else if (thisLayer.index=b){
thisComp.layer("control").effect("color2")("color")
}
else if (thisLayer.index=c){
thisComp.layer("control").effect("color2")("color")
}
else{
thisComp.layer("control").effect("color4")("color")
}
I am looking for an expression that works for every layer, independently from the number of layers or colors.
set variable via index
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
This should work:
thisComp.layer("control").effect("color" + index)("Color")
Dan
thisComp.layer("control").effect("color" + index)("Color")
Dan
I'd do it completely differently. You could simply use the modulus with a divisor of 4 (%4) as the criteriacharles art wrote:Hi. I have a bunch of layers with the "circle"-effect applied on it. I have a "control"-layer with 4 defined colors. The aim is:
Layer1: color1
Layer2: color2
Layer3: color3
Layer4: color4
Layer5: color1
Layer6: color2
...(and so on)
This is my lousy try, but it doesn't work:
(applied on the color option of the circle effect)
var a = ('1','5',...);
var b = ('2','6',...);
var c = ('3','7',...);
var d = ('4','8',...);
if (thisLayer.index=a){
thisComp.layer("control").effect("color1")("color")
}
else if (thisLayer.index=b){
thisComp.layer("control").effect("color2")("color")
}
else if (thisLayer.index=c){
thisComp.layer("control").effect("color2")("color")
}
else{
thisComp.layer("control").effect("color4")("color")
}
I am looking for an expression that works for every layer, independently from the number of layers or colors.
if (index%4 == 0)
{color a}
else if ((index+1)%4 == 0)
{color b}
else if ((index+2)%4 == 0)
{color c}
else {color d}
Would be more flexible than hacking in all indizes first.
Mylenium
[Pour Mylène, ange sur terre]
-
- Posts: 2
- Joined: November 11th, 2007, 12:01 pm
Cooooool, that's exactly what I wanted. Thank you very much, Mylenium!Mylenium wrote:[
I'd do it completely differently. You could simply use the modulus with a divisor of 4 (%4) as the criteria
if (index%4 == 0)
{color a}
else if ((index+1)%4 == 0)
{color b}
else if ((index+2)%4 == 0)
{color c}
else {color d}
Would be more flexible than hacking in all indizes first.
Mylenium