I’m creating a simple drawing application that adds new Shape objects to a MovieClip “canvas” every time the user clicks and drags. The problem is, I’m noticing that even though the MouseEvent listeners are set to the MovieClip, the child Shape objects are being returned as targets as well. This disrupts the localX and localY as well, causing the drawing cursor to jump around as the coordinates change from being local to the entire MovieClip to local to the Shape the mouse is currently over.
Is there any way to retrieve the most parental target from a MouseEvent?
you maybe simply wanna set
DisplayObjectContainer::mouseChildrentofalse… other than that, you can thecurrentTarget, which should be yourMovieClipand use itsDisplayObject::mouseXandDisplayObject::mouseY… or you could use theMouseEvent::stageXand theMouseEvent::stageYand thenDisplayObject::globalToLocalto transform it to yourMovieClip‘s coordinate space …little sidenote: why
MovieClipand notSprite?edit: the actual point, why i don’t like using
MovieClipis, that it’s dynamic, so you get no compiler errors on typos …greetz
back2dos