A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: drag-drop/multiple MCs

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Location
    India
    Posts
    28

    drag-drop/multiple MCs

    Hi,

    I have this code:

    Actionscript Code:
    public class myHitTest extends MovieClip
        {
    var myClip:MyClip;
            public function myHitTest()
            {
                init();
            }
           
            public function init():void
            {
               
    myClip = new MyClip();
    addChild(myClip);
    myClip.addEventListener(Event.ENTER_FRAME,_enterFrame);
                myClip.addEventListener(MouseEvent.MOUSE_DOWN, startDragging);
                myClip.addEventListener(MouseEvent.MOUSE_UP,stopDragging);
            }
           
            private function startDragging(event:MouseEvent):void
            {
                myClip.startDrag();
            }
           
            private function stopDragging(event:MouseEvent):void
            {
                myClip.stopDrag();
            }
        }

    if I had more than one MovieClips that should be dragged. how should I change the code for xample I have another MC called myOtherClip and I want it also to use the functions startDraggging() and stopDragging() but I dont want to write myOtherClip.startDrag();
    and so on.

    I want to have multiple MCs to be able to be dragged.
    thanks!

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Put the dragging behavior in the MyClip class, or some superclass that all your draggables extend.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center