Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Storing a list of properties in a variable

  • Storing a list of properties in a variable

    Posted by Campion Kirkham on December 4, 2020 at 5:14 am

    I have a list of properties that I want to iterate through to see if they are keyed:

    var testLayer = compItem.layer(1);
    var testProps = ["Position", "Opacity"];
    //This line returns the correct number of position keys on the first layer
    $.writeln(testLayer.Position.numKeys);
    //This line returns the correct number of opacity keys on the first layer
    $.writeln(testLayer.Opacity.numKeys);
    //Both of these lines error out as "undefined is not an object"
    $.writeln(testLayer.testProps[0].numKeys);
    $.writeln(testLayer.testProps[1].numKeys);

    Why is it that I am able to access each property’s keys by directly putting in the string name, but putting that same string in a variable returns undefined?
    Thanks!

    Campion Kirkham replied 5 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    December 4, 2020 at 3:36 pm

    Try it this way:

    $.writeln(testLayer.property(testProps[0]).numKeys);

    $.writeln(testLayer.property(testProps[1]).numKeys);

  • Campion Kirkham

    December 9, 2020 at 5:41 pm

    That worked like a charm, thanks so much!

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