An expression error occurs only prior to a marker
I have a shape layer (let's call it "Shape layer") that its position "In" animation is triggered by a marker that is on another layer in an other composition (let's call it "Controller layer").
everything works fine, but I have an error appears on the position expression on "Shape layer" only when the time indicator is located before the first marker on the "Controller layer".. whenever the time is ahead of the marker, the error disappears.
There are three shape layers and the issue occurs on all three of them.
This is the error:
Error: Undefined value in expression (could be an out of range array subscript?)
This is the expression written on the position of the "Shape layer":
m = comp("ASA_LL_sky_UI").layer("Click controller A").marker.key(2).comment;
const cm = comp("ASA_LL_sky_UI").layer("Click controller A").marker;
const catM = comp("ASA_LL_sky_UI").layer("Sky CAT controller").marker;
let latestMarkerIndex = 0;
if (catM.numKeys > 0) {
latestMarkerIndex = cm.nearestKey(time).index;
if (cm.key(latestMarkerIndex).time > time) {
latestMarkerIndex--;
}
}
let outputText = "";
if (latestMarkerIndex > 0) {
const latestMarker = cm.key(latestMarkerIndex);
outputText = latestMarker.comment;
};
menus = comp("ASA_LL_sky_UI").layer("Sky CAT controller").effect(1)("Menu").value;
yVals = [371,634,896,1157,1416,1684,1950,2208,2470,2730,2995,3254,3515,3781,4038];
m = outputText-1;
y = yVals[menus-1];
result = [
[ 159.0632 , y ],
[ 349.0632 , y ],
[ 540.0632 , y ],
[ 731.0632 , y ],
[ 920.0632 , y ]
];
result[m];
