Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Looping through numProperties always ends with error: undefined

  • Looping through numProperties always ends with error: undefined

    Posted by Hugo Van den doel on June 24, 2019 at 4:08 pm

    Working on a function that checks wether the selected layer has a specific effect applied to it. Here’s a simplified version of it:

    function hasTransformEffect(layer) {
    for (i = 1; i <= layer.Effects.numProperties; i++) {
    alert(i);
    }
    }

    alert(hasTransformEffect(app.project.activeItem.selectedLayers[0]));

    When running this, I always end up with an undefined after it’s finished looping. Here’s a video of me trying this https://streamable.com/bcg48

    Few things I have tried:
    – Using a try/catch to bypass it
    – Using an if statement to check wether numProperties > 0 before running the loop
    – Running it from Extendscript IDE
    – Running it from a saved .jsx file
    – Running it on a different machine
    – Running it on a different version of AE

    Wondering what I’m missing, I’m assuming it’s something about numProperties that I don’t know. Any help is greatly appreciated!

    Hugo

    Andrei Popa replied 6 years, 10 months ago 2 Members · 1 Reply
  • 1 Reply
  • Andrei Popa

    June 25, 2019 at 6:19 am

    Why do you use the last alert? That is what give undefined. You have an alert inside the function that works ok. Then, when you try to allert the result of the function, it is undefined. To change that either remove the last alert, or return something with the function.

    Andrei
    My Envato portfolio.

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