Assuming I have a button named "btnTest" on stage and I want to get the instance name . Normally we usually code like this:
btnTest.addEventListener(MouseEvent.CLICK, clkTest);
private function clkTest(e:MouseEvent):void {
trace(e.target.name) // It'd output something random like "instance61" instead of the instance name of the MC you are targeting,
}
you should change a little bit, just 1 line of code, like this:
e.currentTarget.name
Finally, I get the proper result.
trace(e.currentTarget.name) // It'd output "btnTest"
0 comments