I'm not a programmer by any means. I'm an animator trying to use JS expressions in After Effects. I'm getting an "Undefined value used in expression" error on line 1 where I define a variable.I already showed it to my friend on discord who is a cs major, and he had no clue what was wrong with it.
Here's just a paste of the code if you need it:
var count = 1;
if (framesToTime(time) % 12 == 0) {
count = count + 1
if (count % 2 == 0){
thisProperty = 95
} else {
thisProperty = 20
};
} ;
I'm not a programmer by any means. I'm an animator trying to use JS expressions in After Effects. I'm getting an "Undefined value used in expression" error on line 1 where I define a variable.I already showed it to my friend on discord who is a cs major, and he had no clue what was wrong with it.
Here's just a paste of the code if you need it:
var count = 1;
if (framesToTime(time) % 12 == 0) {
count = count + 1
if (count % 2 == 0){
thisProperty = 95
} else {
thisProperty = 20
};
} ;
Share
Improve this question
edited May 12, 2020 at 21:27
M A Salman
3,8202 gold badges13 silver badges27 bronze badges
asked May 12, 2020 at 21:07
Henry FairbanksHenry Fairbanks
711 gold badge1 silver badge3 bronze badges
3
-
This part of your code
framesToTime(time)
is not defined, it references a function that's not defined in the snippet you posted here unless there are other parts to your code not here – dqve Commented May 12, 2020 at 21:15 - @dqve framesToTime is afterEffect's inbuilt function.So no point of problem up there. – M A Salman Commented May 12, 2020 at 21:18
- 1 I suspect it has something to do with "count declaration" – M A Salman Commented May 12, 2020 at 21:19
4 Answers
Reset to default 2Ok I don't know why the hell this fixed it, but I changed the name of the variable from "count" to just "x" and it works now. Go figure
Try it.
var count = 1;
if (framesToTime(time) % 12 == 0) {
count = count + 1;
if (count % 2 == 0){
thisProperty = 95;
} else {
thisProperty = 20;
}
}
thisProperty;
In your code, thisProperty has bee an ordinary variable. If you write its name at the end of the code, then its value will be assigned to the property.
In AE, if there is nothing inside an if
statement or the if
statement contains malformed/error code you will receive this error. Put a temp value inside the curly braces or something to process and ensure nothing inside will throw an error.
I also received this error with this:
pastTime = timeToFrames(time)-1;
curPos = transform.xPosition;
pastPos = transform.xPosition.valueAtTime(framesToTime(pastTime));
if (curPos-pastPos[0] != 0) {
// Here is the problem in my case. added a value here 99
to fix until finished testing.
}
else {
effect("Angle Control")("Angle")
}
if/else statements are strict
The syntax for if/else statements is strict in the JavaScript engine and need to be written for standardized JavaScript.
https://helpx.adobe./after-effects/using/expression-language-reference.html*
I got this error because there was a missing semicolon.