Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression error but still getting correct value

  • Expression error but still getting correct value

    Posted by Juan Irache on September 25, 2019 at 12:10 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

    Juan Irache replied 6 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 25, 2019 at 6:11 am

    Try changing the last line to this:

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

    Dan

  • Juan Irache

    September 25, 2019 at 10:55 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!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy