ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to doing this script work with looping?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
adi pratama
How to doing this script work with looping?
on Mar 1, 2017 at 6:13:16 pm

Hi, this script work perfectly. But, how to doing this with loop?
i don't understand how to using this format:

var i;
for (i = 0; i < 8; i++)


Thank you in advance.
Below my dirty script:

var c, oc, oLayer;
c = 1;
oLayer = "enable-layer-style";
oc = "Checkbox";

var checkboxName;
checkboxName = ["green", "blue", "red", "purple", "grey", "black", "white", "orange", "pink"] ;
if(thisComp.layer(oLayer).effect(checkboxName[0])(oc) == c) {
2;
} else if(thisComp.layer(oLayer).effect(checkboxName[1])(oc) == c) {
3;
} else if(thisComp.layer(oLayer).effect(checkboxName[2])(oc) == c) {
4;
} else if(thisComp.layer(oLayer).effect(checkboxName[3])(oc) == c) {
5;
} else if(thisComp.layer(oLayer).effect(checkboxName[4])(oc) == c) {
6;
} else if(thisComp.layer(oLayer).effect(checkboxName[5])(oc) == c) {
7;
} else if(thisComp.layer(oLayer).effect(checkboxName[6])(oc) == c) {
8;
} else if(thisComp.layer(oLayer).effect(checkboxName[7])(oc) == c) {
9;
} else if(thisComp.layer(oLayer).effect(checkboxName[8])(oc) == c) {
10;
} else {
1
}


Return to posts index

Dan Ebberts
Re: How to doing this script work with looping?
on Mar 1, 2017 at 9:56:55 pm

I can't tell what you're doing exactly, but it would probably be something like this:


for (var i = 0; i < checkboxName.length; i++){
if(thisComp.layer(oLayer).effect(checkboxName[i])(oc) == c) {
result = i+2;
break;
}
}
result



Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]