Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Sep 12, 2024 Sep 12, 2024

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 }

 

TOPICS
Expressions
742
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 12, 2024 Sep 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"
...
Translate
New Here ,
Sep 12, 2024 Sep 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 12, 2024 Sep 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")
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 13, 2024 Sep 13, 2024
LATEST

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines