ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Looping through numProperties always ends with error: undefined

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hugo van den Doel
Looping through numProperties always ends with error: undefined
on Jun 24, 2019 at 4:08:46 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


Return to posts index

Andrei Popa
Re: Looping through numProperties always ends with error: undefined
on Jun 25, 2019 at 6:19:20 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.


Return to posts index

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