Get coordinates in parent, but not in stage
Question
I know about Flash's localToGlobal
and globalToLocal
methods to transform coordinates from the local system to the global system, but is there a way to achieve the intermediate? To transform coordinates from an arbitrary system to any other arbitrary system?
I have a clickable object inside a Sprite, and the Sprite is a child of the stage. I want to retrieve the clicked point in the Sprite.
Solution
you can use the following:
var m:Matrix = a.transform.matrix.clone();
m.invert();
bCoord = m.transformPoint(aCoord);
looks a little verbous, due to the really stupid signature of invert, but when clips are nested deeply, it should be faster.
sorry, just reread your question. if you only want to find out the clicked point, then you can do globalToLocal
with the MouseEvent
's stageX
and stageY
.
greetz
back2dos
OTHER TIPS
While typing I came up with the answer. I figured I'd post the question anyway so that others may find it by search.
bCoordinate = b.globalToLocal(a.localToGlobal(localPoint));