Frustrated,...
So if you have ever encountered this :
head1.addEventListener(MouseEvent.CLICK, headClick);
private function headClick(e:MouseEvent):void {
trace(e.target.name)
}
// outputs something random like "instance22" instead of the instance name of the MC you are targeting, which in this case is "head1".
So after some searching and anger, (I still don't know why but this is only a random occurrence for me), if you add currentTarget in place of target
like so:
e.currentTarget.name
I get the proper results.
trace(e.currentTarget.name) // outputs "head1"; woohoo!
so if you keep seeing instance22, or instance286 instead of the instance name your looking for,. try the above.
if it still doesn't work, then something else is wrong,...
;}
Monday, December 29, 2008
e.target.name not working - as3 gotcha
Posted by shane michael colella at 1:48 PM 19 comments
Labels: as3, as3 e.target gotcha, currentTarget.name, e.currentTarget, e.target instance name, e.target.name, flash, instance name
Subscribe to:
Posts (Atom)