ActionScript 3 事件.目标
我有一个名为“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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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. Useevent.currentTarget
instead.Check out this blog post to learn more.