Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions scripting Q: simple for loop, how to read the counter as a number ?

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

    Posted by Shai Benshoshan on February 26, 2019 at 1:09 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;
    };

    Shai Benshoshan replied 7 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    February 26, 2019 at 4:00 pm

    I think the second line needs to be like this:

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

    Dan

  • Shai Benshoshan

    February 27, 2019 at 8:13 am

    Thanks ☺

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy