开发者

Get coordinates in parent, but not in stage

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 开发者_StackOverflow社区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.


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));


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜