Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Selecting specific Function depending on two sliders

  • Selecting specific Function depending on two sliders

    Posted by Pj Palomaki on March 21, 2018 at 5:27 pm

    Hi,

    I’ve got a good number of easing functions and they’re named like so:

    inoutQuint()
    inQuint()
    outQuint()

    I’d like to switch between functions with two sliders, one for ease type (i.e. Quint) and another for which sided easing I want (i.e. out).

    What would be the best way to choose the function using those two sliders? I tried constructing a switch statement like so:

    switch (easeSelect) {
    case 1:
    ease = "Sine";
    break;
    case 2:
    ease = "Quad";
    break;
    case 3:
    ease = "Quart";
    break;
    case 4:
    ease = "Quint";
    break;
    case 5:
    ease = "Circ";
    break;
    case 6:
    ease = "Expo";
    break;
    case 7:
    ease = "Bounce";
    break;
    case 8:
    ease = "Back";
    break;
    case 9:
    ease = "Elastic";
    break;
    default:
    return null;
    }

    switch (easeType) {
    case 1:
    easeType = "in";
    break;
    case 2:
    easeType = "out";
    break;
    case 3:
    easeType = "inout";
    break;
    default:
    return null;
    }

    The problem is that I can’t construct a function out of that as the ease and easeType are string variables so something like this doesn’t work:

    var func = easeType + ease;

    Is there any other way to go around this apart from nested switches?

    Cheers,
    PJ

    ————————————————–

    Freelance Cinematographer, Camera Op, Video Editor and Motion Graphics Designer

    http://www.pjpalomaki.com

    Andrei Popa replied 8 years, 1 month ago 2 Members · 1 Reply
  • 1 Reply
  • Andrei Popa

    March 22, 2018 at 8:08 am

    You need the ease or you want to make the expression. Because if what you are looking for is an easy way to ease(omg, how this sounds :))) you can check this out. It’s “name your own price”, so you can download it free, and then pay the author if you feel like they made your life easier(i think this script will). Plus, this script is not binary encrypted, so you can also see the code. Maybe you can find your answer(or maybe more than what you are looking for) in his code. I have seen it, very clean and well commented.

    Andrei
    My Envato portfolio.

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