I have a MovieClip with a MouseEvent function associated to CLICK event. Inside of this MovieClip I have a TextField.
So, when I click on my MovieClip, the handler works fine. Now I need the same behaviour when I click on this TextField, but without change my handler function. I mean, I don’t want to change e.target to e.target.parent if user clicked on TextField instead of MovieClip.
How can I do this?
Some of my source code:
public function Main(){
var m = new menu();
menuMng.addChild(m);
m.addEventListener(MouseEvent.CLICK, openMenu);
}
private function openMenu(e:MouseEvent):void{
// Do some stuff
}
Thanks in advance!
This is a fairly common question – you can use the
event.currentTargetproperty instead ofevent.targetto reference the object to which you added the event listener.For a more detailed answer check out this question (don’t worry about the Flex aspect of it – this relates to standard Actionscript 3 behaviour):
What is the difference between target and currenttarget in flex?