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

Project expression errors - undefined value

New Here ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

First timer here and I appreciate anyone's time to help educate me a bit. I have an older aep file that the expressions are erroring out. I admit, I know absolutely zero about expressions in AE, I'm an extreme novice here. Below are the two expressions, I would welcome any direction/guidance on how to resolve these issues:

 

EXPRESSION ONE:

x = Math.round(effect("Camera Angle")("Slider"))

Error: Undefined value used in expression (could be an out of range array subscript?)
if (x > 6) {
    6
}
if (x < 1) {
    1
}

 

EXPRESSION TWO:

x = Math.round(effect("Scene Setup")("Slider"))

Error: Undefined value used in expression (could be an out of range array subscript?)
if (x > 4) {
    4
}
if (x < 1) {
    1
}

 

If more context is needed to resolve the issue, I will try to provide what I can - the use case is that it shifts the camera point of view around 6 different positions, from zoomed out , zoomed in, and zoomed into the four corners of the screen. Not sure if that helps or not.

 

Again your feedback and guidance is appreciated.

TOPICS
Expressions

Views

170

Translate

Translate

Report

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 ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

The first expression doesn't define what happens if the slider is between 1 and 6. The second expression has the same issue for values between 1 and 4.

For the first expression, you might be looking for something like this:

x = Math.round(effect("Camera Angle")("Slider"));
clamp(x,1,6)

Votes

Translate

Translate

Report

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
LEGEND ,
Aug 16, 2023 Aug 16, 2023

Copy link to clipboard

Copied

You may want to read ho this stuff actually works in the online help you and educate yourself about basics of Javascript. Your code makes absolutely no sense even on the most basic level from not adhering proper if()else{} syntax to not even using a single reserved keyword to tell AE what it is supposed to do. Since you seem to treat those numbers as indices, the actual position values would have to be defined somewhere as well and then you can't just use plain number. So perhaps it should look more like this:

 

centX=thisComp.width*0.5;

centY=thisComp.height*0.5;

 

viewDef=[centX,centY,0]

viewA=[200,300,0];

viewB=[400,800,0];

 

if (x > 6)

{mView=viewB}

else if (x < 1)

{mView=viewA}

else

{mView=viewDef};

 

[mView[0],mView[1],mView[2]]

 

Mylenium

 

 

 

Votes

Translate

Translate

Report

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 ,
Aug 17, 2023 Aug 17, 2023

Copy link to clipboard

Copied

LATEST

Thank you both for your feedback, I agree, I have much to learn and plan to dig into it. having the context from your responses will help greatly.

 

cheers.

Votes

Translate

Translate

Report

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