PDA

View Full Version : A question about .target



endy
June 13th, 2008, 03:03 PM
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.

senocular
June 13th, 2008, 04:42 PM
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.

endy
June 13th, 2008, 05:14 PM
Ah, that did it. Thanks so much!