3 Replies Latest reply on Oct 31, 2011 9:45 AM by Ned Murphy

    An If using dropzones

    adeking Level 1

      Hi,

       

      A student of mine is wanting to create a drag and drop game in which the user selects a possible answer for a range, drags it over a object named as "dropzone".

       

      If the correct answer is left over the dropzone, and the user clicks the check button they need to be sent to a frame displaying "correct" - otherwise, sent to a frame for incorrect.

       

      I currently have a set up in which the user is given an auto response using a dynamic text box and all is done on the one frame, but this student wants to be a little different.

       

      Any help with the actionscript will be much apreciated.

       

      Thanks

       

      Adrian.

        • 1. Re: An If using dropzones
          Ned Murphy Adobe Community Professional & MVP

          Instead of writing to a textfield they just use gotoAndStop("correct") versus gotoAndStop("incorrect"),  where the frames have labels of that naming.  Just curious, what are you teaching?

          1 person found this helpful
          • 2. Re: An If using dropzones
            adeking Level 1

            Hi Ned,

             

            Thanks for the response.  I am teaching A Level ICT and in particular a unit titled Interactive Multimedia.

             

            I am no expert on Flash as you can probably tell and still cannot get my head around how to alter the game.  I have the following code allied to the Drag object....

             

            on(press) {
            startdrag(this);
            }

            on(release) {
            stopdrag();
            switch(this._droptarget) {
            case "/dropA":
            case "/dropC":
            case "/dropD":
            _root.answer.text="Hopeless";
            break;
            default:
            _root.answer.text="";
            break;
            }
            }

             

            I need to obviously keep the drag code on the object which is no problem, but not sure how to convert the rest of the code to be appropriate for a check button which then uses gotoandstop to take theu ser to correct, incorrect frames.

             

            Thanks 

            • 3. Re: An If using dropzones
              Ned Murphy Adobe Community Professional & MVP

              Actually putting code on the drag object or any object is a bad practice that is best to get away from early in life.  You should assign an instance name to your dragged object and assign code to it via the timeline in which it sits.  In the code below I've named it "dragee"

               

              dragee.onPress = function() {
                  startdrag(dragee);
              }

              dragee.onRelease = function() {
                  stopdrag();
                  switch(dragee._droptarget) {
                     case "/dropB":
                        answer.text = "good one";

                        gotoAndStop("correct");
                        break;
                    case "/dropA":
                    case "/dropC":
                    case "/dropD":
                       answer.text="Hopeless";

                       gotoAndStop("incorrect");
                       break;
                    default:
                       answer.text="";
                       break;
                  }
              }

              1 person found this helpful