Copy link to clipboard
Copied
I have the following expression I need to use over 144 layers. I want to store it somewhere so if I need to change the expression, I don't have to modify all 144 layers:
function loadColorBar(month) {
eval("var tempAnomaly=" + footage("AnnualTempAnomalies.json").sourceText);
//indexes: 0 - Jan, 1 - Feb, etc.
eval(" MonthData = (tempAnomaly[month].col" + thisComp.layer("Root").effect("Year")("Slider") + "+3.5)*100");
sampleRadius = [1,1]
return comp("Gradient Scale").layer("gradient").sampleImage([MonthData,5],sampleRadius)
}
I've loaded the file into After Effects and am trying to use the following eval expression:
eval(footage("ColorBars_GlobalFunctions.txt").sourceText);
loadColorBar(0);
Unfortunately it's throwing "ReferenceError: month is not defined"
This is telling me it's able to reference the file and it's found my function, but it's not liking the fact that my function is holding a variable. Any ideas how I can make this work? I feel like I'm so close to a solution!
Have something to add?