获取父级坐标,但不在舞台中

发布于 2024-09-01 22:33:49 字数 179 浏览 12 评论 0原文

我知道Flash的localToGlobalglobalToLocal方法将坐标从本地系统转换为全局系统,但是有没有办法实现中间呢?将坐标从任意系统转换为任何其他任意系统?

我在 Sprite 中有一个可点击的对象,并且 Sprite 是舞台的子级。我想检索精灵中的点击点。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

べ映画 2024-09-08 22:33:49

在打字时我想出了答案。我想无论如何我都会发布这个问题,以便其他人可以通过搜索找到它。

bCoordinate = b.globalToLocal(a.localToGlobal(localPoint));

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));
疏忽 2024-09-08 22:33:49

您可以使用以下命令:

var m:Matrix = a.transform.matrix.clone();
m.invert();
bCoord = m.transformPoint(aCoord);

看起来有点冗长,因为 invert 的签名非常愚蠢,但是当剪辑嵌套得很深时,它应该更快。

抱歉,请重读您的问题。如果您只想找出点击点,那么您可以使用 MouseEventstageXstageY 执行 globalToLocal代码>.

问候
后退2dos

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文