开发者

AS3 - Getting the mouse targets children one level deep

开发者 https://www.devze.com 2023-02-06 15:05 出处:网络
I want to find only the first level of children. Right now I\'m using e.target.name but this is also catching those ta开发者_如何学运维rgets children. How would I prevent this?I see three possibilitie

I want to find only the first level of children. Right now I'm using e.target.name but this is also catching those ta开发者_如何学运维rgets children. How would I prevent this?


I see three possibilities:

  • Set all of your one level children as mouseChildren=false.
  • Link the events directly to the children and use currentTarget.
  • Traverse the target's hierarchy until you find the right parent:

something like this:

var clip:DisplayObject=e.target;
while(clip.parent!=e.currentTarget) {
    clip=clip.parent;
}


Setting mouseChildren = false; on any DisplayObjectContainer will disable mouse events on all its children.

0

精彩评论

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