ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression error but still getting correct value

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Juan Irache
Expression error but still getting correct value
on Sep 25, 2019 at 12:10:26 am

Hi,

I am getting an intermittent error (it comes and goes without me toching or playing anything) on an expression, but the value it outputs is still correct.

My code looks something like this:

mSource = thisComp.layer("Control").effect("mgJSON Source")(1); //Select a source layer
arr = thisComp.layer("distanceCalculator").text.sourceText.valueAtTime(mSource.inPoint); //Read array formatted as string
mIndex = timeToFrames(time - mSource.inPoint); //Find necessary frame
vals = arr.split(','); //Convert to actual array
vals[mIndex]; //Return value of frame


And the error I'm getting is:

AE warning: Expression Disabled
Error at line 1 in property 'Slider' of layer 6 ('preCalculations') in comp 'DISTANCE'.

Undefined value used in expression (could be an out of range array subscript?)


I'm only getting the error if I trim (change the inPoint) of the source layer. The "vals" array has all necessary values, including the one at index "mIndex". In fact, if I return vals[421] (or whatever the frame index is), I don't get the error.

Is this just bad error reporting? I am wild guessing the "vals" array is missing its values at some point during After Effects' calculations, but it comes back in time to return the right value.

Thanks


Return to posts index

Dan Ebberts
Re: Expression error but still getting correct value
on Sep 25, 2019 at 6:11:26 am

Try changing the last line to this:

vals[clamp(mIndex,0,vals.length-1)];


Dan



Return to posts index

Juan Irache
Re: Expression error but still getting correct value
on Sep 25, 2019 at 10:55:17 pm

Thanks. That seems to have gotten rid of the error. This will also come in handy for those cases when I was combining Math.max and Math.min!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]