ActionScript 3 事件.目标

发布于 2024-12-29 03:55:44 字数 513 浏览 6 评论 0原文

我有一个名为“button1”的影片剪辑,在此影片剪辑中 有一个名为 txt 的动态文本,

 public function mouse_down(event:MouseEvent)
      {
      if(event.target==button1)
      {
      ...//this only recognizes when i click the button without intersecting the dynamic text area
      }
      if(event.target==button1||event.target==button1.txt)
      {
      ...//this works
      }

我想知道为什么它无法识别在包含动态点击的区域中进行的点击(如果我不指定它),因为 txt 是 button1 的一部分,所以通常我只需要检查目标是否为button1,但它不起作用:我还必须检查目标是否为button1.txt

感谢您的帮助!

I have a movie clip named button1 and in this movie clip
there is a dynamic text named txt

 public function mouse_down(event:MouseEvent)
      {
      if(event.target==button1)
      {
      ...//this only recognizes when i click the button without intersecting the dynamic text area
      }
      if(event.target==button1||event.target==button1.txt)
      {
      ...//this works
      }

i would like to know why it dosen't recognize clicks made in the area that contains the dynamic click if i don't specify it, because txt is part of button1, so normally i would only need to check if the target is button1 but it dosen't work:i also have to check if the target is button1.txt

Thanks for your help!

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

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

发布评论

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

评论(1

满身野味 2025-01-05 03:55:44

event.target 始终指向事件源自的对象,即使它嵌套在您添加侦听器的对象中。请改用 event.currentTarget

查看 这篇博文了解更多信息。

event.target always points to the object the event originated from, even if it is nested in the object you added the listener to. Use event.currentTarget instead.

Check out this blog post to learn more.

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