Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions index number driven by a variable?!

  • index number driven by a variable?!

    Posted by Peter Menich on May 25, 2009 at 6:19 pm

    Hey all,

    I’m trying to build a comp that looks at the layers of another comp and takes the position of a desired layer. what I have so far is this…

    temp = comp("NamesList").layer(135).transform.position.valueAtTime(0);
    x = temp[0];
    y = temp[1];

    [x,y]

    This works fine, but I wanted to add an expression control slider that drives the desired index number, like this…

    numBer = effect("layer number")("Slider");

    temp = comp("NamesList").layer(numBer).transform.position.valueAtTime(0);
    x = temp[0];
    y = temp[1];

    [x,y]

    Which doesn’t work! I get this error…

    After Effects warning: Bad Argument: Layer index 671826536 out of range

    any ideas?!

    Peter Menich replied 16 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 25, 2009 at 7:24 pm

    See if this works better:

    numBer = Math.round(effect(“layer number”)(“Slider”));

    if (numBer <= comp("NamesList").numLayers && numBer > 0){

    temp = comp(“NamesList”).layer(numBer).transform.position.valueAtTime(0);
    x = temp[0];
    y = temp[1];

    [x,y]

    }else{
    value
    }

    Dan

  • Peter Menich

    May 26, 2009 at 8:44 am

    Mr Ebberts.

    I am, as usual, humbled.

    Works like a treat!

    Many thanks.

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