3 Replies Latest reply on Nov 16, 2012 6:10 AM by joel_pau

# how can i know the x position of an element on stage?

i there any way to know the x,y position of an element in stage?

thanks!

• ###### 1. Re: how can i know the x position of an element on stage?

yes, there is a jQuery function: .position().

Now, i add a rectangle on stage, then i open compositionReady to write:

var position = sym.\$("Rectangle").position();

console.log( "(x) or left: " + position.left + ", (y) or top: " + position.top );

• ###### 2. Re: how can i know the x position of an element on stage?

I have a circle in x=256 and y= 146 and with position.top and position.left returns 0 ¿?

var coord_x = sym.\$("punto_1").position();

sym.getComposition().getStage().\$("test_text").html("x:" + coord_x.left);

thanks!

• ###### 3. Re: how can i know the x position of an element on stage?

Well, it works fine. Here is a demo file: file attached.

Where are you writing your code? What panel ?

I tried these lines and they run fine:

var position = sym.\$("Rectangle").position();

console.log( "x or left: " + position.left + ", y or top: " + position.top );

var x = sym.\$("Rectangle").position().left;

var y = sym.\$("Rectangle").position().top;

console.log("x=",x,"y=",y);

var coord = sym.\$("Rectangle").position();

sym.getComposition().getStage().\$("test_Text").html("x:" + coord.left + "<br>y:" + coord.top);

//sym.\$("test_Text").html("x:" + coord.left + "<br>y:" + coord.top);