hi everyone!
i´m new to these expressions stuff, even though i´ve used some copypasted code now and then. i like programming (the very little i know of actionscript or java), so don´t mind explaining every bit! (heheheh)
let´s get to it: i´m working on a typical bullseye vision, like terminator´s eye. i have a center, and two lines (horizontal and vertical). i want to animate the center´s position, and that the lines move along with it.
so i thought: "let´s link the horizontal line to the center´s Y axis, and the vertical line to the center´s X axis". like, with the whip, right...? ... ... apparently not.
i kept thinking, cause everytime i mess with the code it shows me errors. i was looking for a way around it, and thought: "maybe if i link the line´s ANCHOR POINT to the center´s X axis position...". THAT WORKED! ... yeah, but exactly the opposite of what i was looking for: every time the center moves to the left, the line goes to the right. and it makes sense, right? since i´m moving it´s anchor point towards the left.
well that´s my current situation. i´m looking for either an expression that links Y axis of a layer to X axis of another layer, or a way to make "invert" of the anchor point expression i created with the whip.
guess this is easy stuff to you, hope i´ll learn something from this. i apologize if my english´s quite messy.
greetings from bariloche, argentina!
linking only one axis position
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
Try this:
// for horizontal layer
c = thisComp.layer("center").position;
[value[0],c[1]];
// for vertical layer
c = thisComp.layer("center");
[c[0],value[1]]
Dan
// for horizontal layer
c = thisComp.layer("center").position;
[value[0],c[1]];
// for vertical layer
c = thisComp.layer("center");
[c[0],value[1]]
Dan
well, that worked just fine!!!
thanks a lot
the vertical one gave me an error message cause ".position" was missing, but i figured that out and fixed it
would you (or anyone) mind explaining to me how this works?
what´s "c" and what is it making with its values?
thanks again.
thanks a lot
the vertical one gave me an error message cause ".position" was missing, but i figured that out and fixed it

would you (or anyone) mind explaining to me how this works?
what´s "c" and what is it making with its values?
thanks again.
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
Oops, sorry about that second one.
"c" is just a variable that is set equal to the center's position. It's not necessary to do this, it just makes things a little easier to read (I think). All the work gets done in the next line:
[value[0],c[1]];
For a 2D layer, the position value is an array with 2 elements - one for x and one for y. Arrays are identified with square brackets in JavaScript.
So if a layer was positioned at the center of a 640x480 comp, it's position could be expressed this way:
[320,240]
"value" refers to the value to the property to which the expression is applied (the horizontal line in this case). So value[0] is the x coordinate and value[1] is the y coordinate.
So that second line in the expression just says "use the x value of my own position and the y value from the center layer's position".
Hope that makes sense. Find a JavaScript reference and look up "arrays" if you want detailed info.
Dan
"c" is just a variable that is set equal to the center's position. It's not necessary to do this, it just makes things a little easier to read (I think). All the work gets done in the next line:
[value[0],c[1]];
For a 2D layer, the position value is an array with 2 elements - one for x and one for y. Arrays are identified with square brackets in JavaScript.
So if a layer was positioned at the center of a 640x480 comp, it's position could be expressed this way:
[320,240]
"value" refers to the value to the property to which the expression is applied (the horizontal line in this case). So value[0] is the x coordinate and value[1] is the y coordinate.
So that second line in the expression just says "use the x value of my own position and the y value from the center layer's position".
Hope that makes sense. Find a JavaScript reference and look up "arrays" if you want detailed info.
Dan
thanks a lot!
i got that, it was so easy... hope once i start writing some expressions (that work, heh) i´ll figure these things out.
you´ve been very helpful!
i got that, it was so easy... hope once i start writing some expressions (that work, heh) i´ll figure these things out.
you´ve been very helpful!