Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions What are Scalar properties?

  • What are Scalar properties?

    Posted by kees mansvelder on February 15, 2021 at 3:39 pm

    I have written this expression to make a hover effect.

    a = thisComp.layer(“Null 1”).transform.anchorPoint;

    s = thisLayer;

    f = s.sampleImage(a,[.1,.1])[3];

    linear(a,0,1,0,100);

    It gives me the “error: argument 1 to linear() must be scalar”

    kees mansvelder replied 5 years, 2 months ago 3 Members · 5 Replies
  • 5 Replies
  • Filip Vandueren

    February 15, 2021 at 5:40 pm

    A scalar is a number, as opposed to an array for example.

    SampleImage will return an array of 4 numbers

    A position or anchorpoint is a vector/array of 2 or 3 numbers (in 3D)

    It looks like you want to do a linear() on the anchorPoint? You would need a[0] to look at the x-value or a[1] for the y-value.

    But perhaps you wanted to look at the alpha of the sampleImage which would be f[3]

  • kees mansvelder

    February 16, 2021 at 9:37 am

    Thanks for your reply!

    What I wanted to do is have some sort of way of instant hover effect. (for tekst highlights in an OS) If I just do linear it will gradually become visible and invisible. I want it to be a hard transition.

    I got it from a youtube channel, and for him it does seem to work with this code which really boggles my mind.

    Therefore I wanted to have the sample image, and then linear the part that needs to be animated. As this whole expression is in the Opacity parameter.

    Should you know of any other way to do this, I’d be really grateful!

  • Robert Müller

    February 16, 2021 at 10:10 am

    There are a few things wrong here. First of all, you want to put the position of the null here instead of the anchorPoint, since I guess you will be using the null as your cursor. Mind that this will not work anymore if the null gets parented, then you have to use some space transformation expression like toComp or toWorld (cant remember which).

    Second you are using the wrong variable in your linear. The first parameter in the linear function is the value you are referencing, in this case the alpha value which you checked for before. So you should insert “f” here instead of “a”.

    a = thisComp.layer("Null 1").transform.position;

    s = thisLayer;

    f = s.sampleImage(a,[.1,.1])[3];

    linear(f,0,1,0,100);

  • Filip Vandueren

    February 16, 2021 at 10:11 am

    I think it just needs to be f instead of a:

    linear(f,0,1,0,100);

    but this will only work if the position of the anchorpoint is indeed at the same position as your coordinates, otherwise sampleImage() is actually samlping somewhere else,

    I don’t know how your cursor is set up to control the null object, but that could be an issue too.

  • kees mansvelder

    February 17, 2021 at 2:12 pm

    Thanks everyone for the replies! You’re right I was just mistyping my code.
    Cheers

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