Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions variable positions with slider control

  • variable positions with slider control

    Posted by Jared Neher on October 17, 2009 at 10:31 pm

    I’d like to create an expression where I can control about 50 layers to move to specific places from a central point by use of a slider. here’s how I set up my comp.

    1. all 50 layers will have an expression for Position which is linked to a slider control on a null layer (see expression code below).
    2. when the slider value is at 0, all 50 layers need to be at the same position (on screen).
    3. when the slider value is at 100, all 50 layers need to be at independent positions. (for instance, imagine a particle explosion)

    I have included the code I’m using for control values for [x,y]. however, all the layers obviously have the same position unless I can customize the code for each layer with an “if/then” statement, or something similar thereof. this is where my knowledge of scripting leaves off. when the slider is at 100, I don’t know how to tell AE that I want a specific layer to be at [-100,-250] and another layer to be at [-50, 425], etc.

    if anyone can give me a quick lesson on variable [x,y] values, I’d appreciate it.
    thanks!

    [this_comp.layer("extrude").effect("Control").param("Slider"), this_comp.layer("extrude").effect("Control").param("Slider")]

    -Jared Neher

    Jared Neher replied 16 years, 7 months ago 3 Members · 3 Replies
  • 3 Replies
  • Xinlai Ni

    October 18, 2009 at 2:37 am

    You gotta specify the [x, y] value for each individual layer somehow.
    Say, on each layer, add an expression Point Control, called “EndPos”, and for each of the 50 layers, assign the desired value.
    Then use this for its position expression:
    linear(thisComp.layer("extrude").effect("Control")("Slider"), 0, 100, startPos, thisLayer.effect("EndPos"))

    where startPos is the same starting position of all these layers.

    Xinlai Ni
    Software Engineer, Google Inc.

  • Dan Ebberts

    October 18, 2009 at 5:37 am

    Each of your layers can have the same expression if you’re willing to define all the ending positions in the expression. For example, this would work for six layers, all starting at [0,0]:

    startPos = [0,0];
    endPos = [
    [-100,-250],[-50,425],[100,100],
    [-100,100],[-100,-100],[50,250]
    ];

    slider = thisComp.layer(“extrude”).effect(“Control”).param(“Slider”);

    linear(slider,0,100,startPos,endPos[index-1])

    You’d just add more destinations to the definition of endPos. This assumes that your control layer is at the bottom of the layer stack (i.e., Layer 1 is the first layer controlled by the slider).

    Dan

  • Jared Neher

    October 19, 2009 at 4:44 am

    thanks for the help! with a few modifications, things are working now just as I need them to. thanks again!

    -Jared Neher

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