-
Adding a null to every comp creates infinityloop
I’m trying to create a script that adds an adjustment-layer to every comp and adds some effects and stuffs to it but first I’m trying to get the code straight. I have looked around and this is the code I find everywhere to make the script go trough all objects, if it’s a comp, add a null into that comp and continue but for me it ends up into an infinityloop and just adds nulls to the first comp it finds.
If I change the code to alert me yes and no if the comp that is found is a CompItem it goes trough the search correctly and no infinityloop, so it seems like it gets stuck in the loop because the addNull();
I have also tried to add “var myComp = null;” in the beginning and the end of the for-loop and the if statement but nothing worked.
I don’t understand what’s wrong =/
var myComp = null;
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i) instanceof CompItem){
var myComp = app.project.item(i);
myComp.layers.addNull();
}
}