inside a MouseEvent.CLICK function, I usually used e.target to address the movieClip that I clicked, but that only work with a movieClip that doesn't have any children (such as text and other symbols) inside. When it has children insid开发者_开发问答e, the e.target return the child inside the Mc but not the Mc itself. The e.currentTarget didn't work, either; it returned [object MovieClip] but not the instance name of the Mc. Is there anyway I can fix it? thank you.
To get the instance name you would need e.currentTarget.name
.
e.target
= element that has been clicked.
e.currentTarget
= element for that a listener has been registered.
Assuming a red box containing a blue box:
red.addEventListener(MouseEvent.MOUSE_CLICK, redClick);
If you click the red box (outside the inner blue one):
e.target
= red
e.currentTarget
= red
If you click the blue box:
e.target
= blue
e.currentTarget
= red
To prevent your blue box dispatching click events you can disable mouse events for child elements:
red.mouseChildren = false;
If you then click the blue box:
e.target
= red
e.currentTarget
= red
Set mouseChildren
of the intended target to false
to stop the events propagating into the MovieClip's children.
精彩评论