Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects numbers interpolation

  • Sam Moulton

    March 18, 2007 at 1:56 am

    btw… doesn’t work with angle control either. It’s really weird. I’m usually pretty good with expressions and java in general but I can’t figure out why this expression is generating an error with the slider control and angle control supplying the numbers and doesn’t give the error when you use either of the point control values [0] or [1].

    There must be something in the way the different expression controls generate numbers, or I’m missing something else…

  • Filip Vandueren

    March 18, 2007 at 2:14 am

    I’ve tested and indeed got the same error…

    Here’s why, and how to fix it:

    The culprit is like I said, numAsText was not a String but a number.
    This has happened because when we refer to:

    num = effect(“Slider Control”)(“Slider”);

    we’re not really referring to a Number, but to a property. The slider itsef as it were.
    Javascript is autotypecasting, meaning a number can become a string when needed (as in +””), and apparantly, a property can become it’s value.

    Strangely when adding the empty string to the slider property, Motionscript does change the property into a number, but forgets to turn it into a string subsequently.
    I suppose this behaviour has changed in an update since I wrote the expression, since I remember testing it then.
    I also consider this a bug because typeof(""+5) will give you “string”

    The fix is easy enough though:

    num = effect("Slider Control")("Slider").value;

    now we’re referring to the actual value of the control, and Motionscript has one less “type to cast”

    also this is a more elegant way of turning the number into a string afterwards:

    numAsText= num.toString();

    So why did the example with the point control work ?

    We were referencing to the first element of a list of numbers: so we indeed had a number, not an object property.
    And Motionscript didn’t have to change it’s type to a number…

    hope that makes sense.

  • Sam Moulton

    March 18, 2007 at 3:24 am

    Thanks…. This opens up a bunch of new ways to use the slider that I have wanted to do for a while.

  • Troy Benesch

    March 19, 2007 at 1:18 am

    Thanks Filip, that did the trick! I appreciate the quick response and assistance. I’m one step closer to getting my brain around scripting.

    Again, thanks.

    Troy

Page 2 of 2

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