Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Drag and drop question

New Here ,
Mar 19, 2013 Mar 19, 2013

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();

          }

 

}

TOPICS
ActionScript
342
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 20, 2013 Mar 20, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 20, 2013 Mar 20, 2013
LATEST

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"?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines