Copy link to clipboard
Copied
I'm sure this is a newb question but I just can't figure it out. I can't seem to drop my movieclip to the location I want it.
I have a movieclip contains text and if it collides with another movieclip it will stop drag but for some reason it just won't do it.
here is my code for the drop
function stopdrag(event:MouseEvent)
{
if (cityname.hitTestObject(objhit))
{
trace("work")
event.currentTarget.stopDrag();
}
}
Copy link to clipboard
Copied
if the thing that should trigger your stopdrag is on a higher Layer than the thing you are dragging and overlays it, the stopDrag won`t happen.
Make sure that while dragging any MovieClip you have an enter_frame function that always put it in front of all other DisplayObkects on stage
Use stage.numChildren and setChildIndex to achieve this.
Copy link to clipboard
Copied
Are you intending for the hit test to be done while the object is being dragged or only when it has been dropped? Your code will only check after the drop has occured assuming the MouseEvent is a MOUSE_UP. If you want it to occur during then you would need another more constant means of listening/checking such as a MOUSE_MOVE or ENTER_FRAME.
Why do you specifically use "cityname" and then less specifically use "event.currentTarget"?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now