set variable via index

Moderators: Disciple, zlovatt

Post Reply
charles art
Posts: 2
Joined: November 11th, 2007, 12:01 pm

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.
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

This should work:

thisComp.layer("control").effect("color" + index)("Color")


Dan
Mylenium
Posts: 139
Joined: July 20th, 2005, 12:07 am

charles 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.
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
[Pour Mylène, ange sur terre]
charles art
Posts: 2
Joined: November 11th, 2007, 12:01 pm

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
Cooooool, that's exactly what I wanted. Thank you very much, Mylenium!
Post Reply