AS3 - Getting the mouse targets children one level deep
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.
精彩评论