Skip to main content
Inspiring
November 23, 2007
Question

globaltolocal

  • November 23, 2007
  • 3 replies
  • 198 views
Hi,

I am trying to check for hittest on movieclips in different other
movieclips (sorry don't find the words). To do that I created a
prototype to convert the coordinates. But it doesn't give me the results
I hoped for.

Here is my code. The trace command should give similar positions when
the clips are at the same position on the screen but they don't.

MovieClip.prototype.getLocalCoordinates = function (targetMc) {
var p= { x : this._x , y : this._y };
this.localToGlobal(p);
targetMc._parent.globalToLocal(p);
return p;
};

p1x = mc1.getLocalCoordinates(mc3);

trace(mc3.mc_unter._x + " " + p1x.x)
if (mc3.mc_unter.hitTest(p1x.x ,p1x.y ,true)){
trace("hit ")
distance = 0;
}


Any ideas what I am doing wrong?
This topic has been closed for replies.

3 replies

Inspiring
November 26, 2007
kglad wrote:
> what do you want your prototype function to do?

found the bug, one "_parent" was missing.
Inspiring
November 26, 2007
kglad wrote:
> what do you want your prototype function to do?

To get the position of a point/clip with the local coordinates of
another clip. Example, to check if the middle point of one clip is
inside another clip on a different timeline (and different
coordinate-system). This is important for rotated clips. Otherwise I
will end in the deep deep world of mathematics. I hoped this makes my
life easier.
kglad
Community Expert
Community Expert
November 24, 2007
what do you want your prototype function to do?