Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Must be scalar” error – linear expression on array value

  • “Must be scalar” error – linear expression on array value

    Posted by Alekos Mazzolotti on December 13, 2021 at 5:31 pm

    Hello, guys!

    Some time ago I was trying to find a way to control the value of a keyframe through an expression, so that I could change the animation, but keep duration and, most of all, the ease I create on the graph editor. After doing some research, I came up with the following expression:

    if (numKeys > 1){

    newV2 = (link to slider);

    v1 = valueAtTime(key(1).time);

    v2 = valueAtTime(key(2).time);

    linear(value,v1,v2,v1,newV2);
    }

    else {value};

    It works like a charm. All I have to do is create 2 keyframes (the second with symbolic value), edit the ease on the graphic panel and voilà. I’ve been using it a lot since then, especially when creating Essential Graphics to work on Premiere.

    But there’s a problem: it only works for properties with one dimension, such as rotation or a separated dimension of the position property, for example. If I try to apply this on a 2-dimensional property, like scale or size, it fails, and AE tells me arguments must be scalar. Changing “value” for “time” inside the linear part has no effect either. The error continues, but instead of “argument 1” it is “argument 2”, then.

    What exactly do I need to change to have it working on array properties?

    I thank you in advance for your help.

    Alekos Mazzolotti replied 4 years, 5 months ago 1 Member · 1 Reply
  • 1 Reply
  • Alekos Mazzolotti

    December 13, 2021 at 5:54 pm

    Hello again!

    Just came up with a solution. I’m sharing it in case anyone else has the same problem. For a 2-dimensional property, the correct form of the expression is:

    if (numKeys > 1){

    v1 = valueAtTime(key(1).time);

    v2 = valueAtTime(key(2).time);

    newV2 = (link to slider);

    x = linear(value[0],v1[0],v2[0],v1[0],newV2);

    y = (value of choice);

    [x,y]

    }

    else{
    value
    };

    If you are looking to change the y value, change the zeroes for “1” and invert “x = ” with “y = “. And there we have it 😎

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