PDA

View Full Version : mouseEvent problems



Zephadias
February 17th, 2009, 01:16 PM
I have unit A: on a mouseEvent: MouseUp and MouseDown event. I'm going click and dragging objects.

Unit A when I pick it up says i have picked up Unit A. I drop it in a location and it stays. GOOD

I pick up Unit B and it says i picked up Unit B. I drop it on top of Unit A and it says I have dropped Unit A. NOT GOOD.

I only want to drop unit B, not A.

So i looked at the events:

target The InteractiveObject instance under the pointing device. The target is not always the object in the display list that registered the event listener. Use the currentTarget property to access the object in the display list that is currently processing the event.

so I use currentTarget instead:

currentTarget The object that is actively processing the Event object with an event listener.

Except they both return the same. Both will register Unit A, even though I am holding Unit A.

Any ideas? This is driving me nuts.
Thanks

irrationalistic
February 17th, 2009, 05:44 PM
I would venture a guess that unit A is getting the mouseUp event because it is sitting on top of unit B. You could set the index of the selected item on mouseDown to the top of the list:


on mouse down {
setChildIndex(e.target, numChildren - 1);
}

The other option would be to set your mouseUp listener in your mouseDown listener as opposed to having it always set. That way you can apply it to a specific object (or the stage for global listening) and already know what unit you are working with!