-
Copy-paste goes wrong
Hi 👋
So I have an expression that work just fine, I have to duplicate it on several others layers, but when I do it, many expression don’t work anymore.
It is strange because the same expression could work on the layer just below the one that is not…
When I move the playhead, some expressions still don’t work and others get fixed by… magic ? 🤔
I really don’t understand, I tried to type the code by hand but nothing changed.
To be more specific, this is the same code, going on shape layers, on fill property.
On every not working expression the same issue is being showed, “Undefined value used in the expression…”
Here’s the code :
f = thisComp.layer("BG").content("Fill 1").color;
colors = [[1, 1, 1, 1],
[0, 1, 1, 1],
[0, 0, 1, 1],
];yellow = [colors[0],
colors[1],
colors[2],
];
purple = [colors[1],
colors[0],
colors[2],
];
pink = [colors[2],
colors[0],
colors[1],
];seedRandom(index,true);
idx = Math.floor(random(colors.length));
if (f.numKeys > 0){
n = f.nearestKey(time).index;
if (time < f.key(n).time) n--;
for (i = 1; i <= n; i++){
idx = (idx + Math.floor(gaussRandom(0,2)))%colors.length;
}
}
if (length(f, colors[0])<0.001){
yellow[idx]
}else if (length(f, colors[1])<0.001){
purple[idx]
}else{
pink[idx]
}