4 Replies Latest reply on Aug 7, 2010 7:19 PM by Ned Murphy

    Drag and Drop CS4



      Does anyone know a good tutorial for drag and drop quiz style? I have managed to actually create the drag and drop but I need it for a quiz (as quiz templates are no longer available past CS3) so need it to tell the user if they are correct or not i.e. drag a word onto a picture and then hit a button that says if its correct or not or something similar.


        • 1. Re: Drag and Drop CS4
          larousse1979 Level 1


          As well as the above question, I have one more with drag and drop.

          The code that I am using below works (its very basic), but it doesnt show that it is a dragable object i.e. no little hand or something hovering over it. Is it possible to do this? Its just to show that they can drag and drop.


          inter.addEventListener(MouseEvent.MOUSE_DOWN , interDrag);
          function interDrag(event:MouseEvent):void{


          inter.addEventListener(MouseEvent.MOUSE_UP , interStopDrag);
          function interStopDrag(event:MouseEvent):void{




          PS: its very hard to get compatibility between AS 2 and 3. Script that works for one wont work for the other.

          • 2. Re: Drag and Drop CS4
            Ned Murphy Adobe Community Professional & MVP

            Use : inter.buttonMode = true;  to get the hand cursor to appear


            AS2 and AS3 with a few exceptions for basic commands (stop(), play(), etc) are entirely different programming languages and cannot be combined in the same fla.

            • 3. Re: Drag and Drop CS4
              larousse1979 Level 1

              Thanks Ned - that worked perfect.


              Any ideas on how to write AS3 code for a drag and drop quiz?

              • 4. Re: Drag and Drop CS4
                Ned Murphy Adobe Community Professional & MVP

                Yes, I have an idea, but I don't have the time or desire to create a tutorial for it.  You basically need to identify the dropTarget of the object that you drag/drop and determine if that object is the object it needed to be dropped onto.


                You could try searching Google using "AS3 dropTarget tutorial" and find some info on how to identify the dropTarget.


                So for your "inter" object, you could maybe assign it a variable holding the instance name of the object it should be dropped on and then compare that against the object to see if they match... OR... you could name the correct target of inter to be "interMatch" and use bracket notation to test if the object dropped's dropTarget matches the object it is dropped on...


                This is a generic function that could be shared by all dragged objects for the latter approach...


                function stopObjectDrag(event:MouseEvent):void{

                     var dragged:MovieClip = MovieClip(event.currentTarget);


                     if(dragged.dropTarget.parent == this[dragged.name+"Match"] ){

                          trace("do whatever to process a correct answer");



                1 person found this helpful