ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

for loop Array

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott McGee
for loop Array
on Mar 19, 2018 at 2:29:52 pm

Hey Guys,

I've seen a few versions of this but not the way I want to use it and struggling to tweak it to work.

I have two arrays.

j = ["BL", "CF", "LS"]
k = ["Bristol", "Cardiff", "Leed"]

I want a for loop to go through the Array and if the indexOf matches my compname it returns the other arrays value.

Example

Compname = BL-TEST

The array will find it is j[0];
and will return k[0];

I can't seem to get this to work at all.


Return to posts index

Scott McGee
Re: for loop Array
on Mar 19, 2018 at 2:56:50 pm

Not sure how I got this to work, but I'm taking it as a win.

Anyone who might be struggling with this here's how I got it to work.

input = thisComp.name;

var myArray = ["BL", "CF", "LS"];
var myResult = ["Bristol","Cardiff","Leeds"]

result = null;
for (var i = 1; i <= myArray.length; i++){
if (input.indexOf(myArray[i]) > -1){
result = i;
break;
}
}
myResult[result]


Return to posts index

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