ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

scripting Q: simple for loop, how to read the counter as a number ?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Shai Benshoshan
scripting Q: simple for loop, how to read the counter as a number ?
on Feb 26, 2019 at 1:09:25 pm

Trying this simple for loop to set the inPoint of 10 layers by this TravelDuration array;

var TravelDuration = [1.5,2.5,3.5,2.5,2,3.5,2,1.5,1,2];
for (var e=0;e<=TravelDuration.length;e++){
var inn=0;
inn = TravelDuration[e];
infoComp.layer(e+1).inPoint=inn;
};
///
the error are "undefind inPoint" or "NaN is not a number" ...

When replacing to a number( inn = 1 ) the script works fine setting all my layers inPoint's to 1sec.

tried this :
//
inn = parseFloat(TravelDuration[parseInt(e.toString())]);
///

with variation, but i cant get it to read // TravelDuration[e] // for the array position(0-9 );

what am I missing?

Thanks

var TravelDuration = [1.5,2.5,3.5,2.5,2,3.5,2,1.5,1,2];
for (var e=0;e&lt;=TravelDuration.length;e++){
var inn=0;
inn = TravelDuration[e];
infoComp.layer(e+1).inPoint=inn;
};


Return to posts index

Dan Ebberts
Re: scripting Q: simple for loop, how to read the counter as a number ?
on Feb 26, 2019 at 4:00:06 pm

I think the second line needs to be like this:

for (var e=0; e < TravelDuration.length; e++){


Dan



Return to posts index

Shai Benshoshan
Re: scripting Q: simple for loop, how to read the counter as a number ?
on Feb 27, 2019 at 8:13:14 am

Thanks ☺


Return to posts index

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