AE ENHANCERS

Expressions/Scripts/Presets
It is currently Wed Oct 22, 2014 4:03 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: set variable via index
PostPosted: Sun Nov 11, 2007 12:37 pm 
Offline

Joined: Sun Nov 11, 2007 12:01 pm
Posts: 2
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 11, 2007 12:55 pm 
Offline

Joined: Sat Jun 26, 2004 10:01 am
Posts: 307
Location: Folsom, CA
This should work:

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


Dan

_________________
http://www.motionscript.com


Top
 Profile  
 
 Post subject: Re: set variable via index
PostPosted: Thu Nov 15, 2007 2:39 am 
Offline

Joined: Wed Jul 20, 2005 12:07 am
Posts: 139
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]


Top
 Profile  
 
 Post subject: Re: set variable via index
PostPosted: Tue Nov 20, 2007 11:17 am 
Offline

Joined: Sun Nov 11, 2007 12:01 pm
Posts: 2
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group