Skip to main content
Participant
September 12, 2024
Answered

"Undefined Value" error in expression, always on line 1, even when line 1 is just a comment

  • September 12, 2024
  • 3 replies
  • 842 views

I'm trying to trigger animations in the position property of one layer using markers on another layer, but the expression keeps returning an error: "Undefined value used in expression (could be an out of range array subscript?)". Weirdly, the error just disappears every now and then until I hover over the timeline again. This error occurs in the first line of code, even when that line is commented out or when I delete the line. For reference, I just updated to v 24.6.2, but even when I rolled back to 24.6.1 the error occurred.

 

If I end the expression with a fixed-value array, such as [5,5], the error disappears, but of course this makes my code redundant.

 

The expression: 

/* 2 states: (1) Normal, for when in left or right view, and (2) Wide, for center view. */
/* This layer will ease() between Normal & Wide for the center values of the master controller layer. */
/* Variables */
control = thisComp.layer("BG_PosControl"); normal = [517, 0]; wide = [-639.5355, 0];
fadeFrames = thisComp.layer("BG_PosControl").effect("TransitionLengthInFrames")("Slider"); m = 0; t = time;

/* Condition Statements */
if (control.marker.numKeys > 0) {
	m = control.marker.nearestKey(time).index;
	tag = control.marker.key(m).comment;
	t = control.marker.key(m).time - time;
	
	if (tag == ("Left"||"Right"||"RightFromLeft"||"LeftFromRight")) { ease(t, framesToTime(fadeFrames), 0, wide, normal) }
	else if (tag == ("CenterFromLeft"||"CenterFromRight")) { ease(t, framesToTime(fadeFrames), 0, normal, wide) }
}
else { value }

 

This topic has been closed for replies.
Correct answer Dan Ebberts

A couple of things. The error reporting for the JavaScript engine has never been as robust as the Legacy engine. For a long expression, it will often report a line number that doesn't exist, or the message will be really vague. Sometimes it helps to switch to the Legacy engine just to see if its error message is more useful. Also, I think  your

if (tag == ("Left"||"Right"||"RightFromLeft"||"LeftFromRight"))

needs to be more like this:

if (tag == "Left" || tag == "Right" || tag == "RightFromLeft" || tag == "LeftFromRight")

3 replies

Participant
September 13, 2024

You got it! I thought it was an AE issue referencing markers on other layers, but it was the tagging convention like you said. Which also explains why replacing the code defining 'm' fixed the issue -- m had an incorrect input. Thanks!

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
September 12, 2024

A couple of things. The error reporting for the JavaScript engine has never been as robust as the Legacy engine. For a long expression, it will often report a line number that doesn't exist, or the message will be really vague. Sometimes it helps to switch to the Legacy engine just to see if its error message is more useful. Also, I think  your

if (tag == ("Left"||"Right"||"RightFromLeft"||"LeftFromRight"))

needs to be more like this:

if (tag == "Left" || tag == "Right" || tag == "RightFromLeft" || tag == "LeftFromRight")
Participant
September 12, 2024

I found the problematic bit of code by plugging and chugging values. 

m = control.marker.nearestKey(time).index; is my problem variable. When I replace this with m = 1; the problem goes away.

 

I don't know why this is happening.