A question about .target

Hello all.

I am trying to do a .gotoAndPlay on a movieClip by clicking on it using an EventListener to call a function. I am able to make this work, however, when I put a movieClip inside the movieClip that I am referencing, it can’t find it. (I trace the name property and get “instance1” instead of the instance name.

Here is what I am doing:

myBut.addEventListener(MouseEvent.CLICK, doit);

function doit( e:Event ) {
	trace(String(e.target.name));
	trace(e.target.x);
}

And here is what traces to the output window:
instance1
0

Anyone know how to make this work?
Thanks.

target is the bottom-most display object in the hierarchy being clicked. Sounds like you want currentTarget which is the object you added the listener to.

Ah, that did it. Thanks so much!