Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects script to get only x position..and what does “++” do?

  • script to get only x position..and what does “++” do?

    Posted by Erin Shelby on October 5, 2005 at 7:35 pm

    hi, I know

    var myLayerPosition = myLayer.position;

    would return an array..

    but how do I just get the x value?

    I know in expressionland it’s “position[0]”. I tried that, but for som reason it doesn’t seem to manipulate the data the same…?

    also, what does “++” do? I know it ‘incriments’, but I’m not sure what it really does. I see it in many scripts.

    Colin Braley replied 20 years, 7 months ago 4 Members · 6 Replies
  • 6 Replies
  • Erin Shelby

    October 5, 2005 at 7:46 pm

    I should mention I’m trying to write a script, that when activiated, will simply move a layer from it’s current position up 10 pixels. And everytime it is run it will move the layer up 10 pixels.

  • Steve Roberts

    October 5, 2005 at 7:51 pm

    How about writing this for position:

    [position[0], position[1]-10]

    Haven’t tested it.
    Steve

  • Erin Shelby

    October 5, 2005 at 7:54 pm

    I believe that is correct, I will test it now. Thanks for the help, sir.

    -echo

  • Dan Ebberts

    October 5, 2005 at 9:39 pm

    This script will do what you want. It assumes your layer is selected:

    var myComp = app.project.activeItem;
    var myLayer = myComp.selectedLayers[0];
    var myCurrentPos = myLayer.property(“position”).value;
    myLayer.property(“position”).setValue(myCurrentPos – [0,10]);

    Dan

  • Steve Roberts

    October 5, 2005 at 10:11 pm

    Much better than my expression. 🙂

    Steve

  • Colin Braley

    October 5, 2005 at 10:54 pm

    ++ is called the “increment operator”. Basicially all it does is add one to a variable. — is the “decrement operator.” Let’s say you had a variable called i.
    i++;
    is the same as saying,
    i = i + 1;

    You will see the this kind of thing most often when you are using loops. Hope my info was what you were looking for.
    ~Colin

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