View Full Version : element.left and top coordinates don't correspond with mouseClick x and y cords

07-27-2006, 05:33 PM
hello I'm trying to perform a mouse click on the middle of an object on a layer. I thought I was having a problem but when I went back and checked later it worked! So I might as well leave this in here as an example of finding the middle of an object using jsfl.
Here is my code:

var el_array = new Array();
el_array[0] = fl.getDocumentDOM().getTimeline().layers[0].frames[fl.getDocumentDOM().getTimeline().currentFrame].elements[0];
var xclick = el_array[0].left+(el_array[0].width/2);
var yclick = el_array[0].top+(el_array[0].height/2);
fl.trace(xclick +" : "+yclick);
//returns 222.025 : 57.900000000000006
//the actual center of the shape location is closer to the cordinates below which
//where produced using the history window in flash. which shows my data is pretty close
fl.getDocumentDOM().mouseClick({x:xclick, y:yclick}, false, true);

//fl.getDocumentDOM().mouseClick({x:243.4, y:55.8}, false, true);

I tried using matrix to but that only alows you to move the shape in relation to its self.