3 Replies Latest reply on Apr 15, 2009 7:05 PM by RossRitchey

    Drag and Drop then Recognize

    goalpost95

      Alright I'm wondering how I can get the landing area to recognize different symbols and then go to a certain frame depending on what symbol is placed in the landing area

       

      here is my code now

       

      onMouseMove = function(){

      updateAfterEvent();

      }

       

      // Design And Culture MC

      desCult.onPress = function(){

      startDrag(this,true)

      }

       

      desCult.onRelease = function(){

      this.stopDrag();

      checkTarget(this);

       

      }

       

      desCult.onReleaseOutside = function(){

      this.stopDrag();

      checkTarget(this);

      }

       

      //Drawing Fire MC

      drawFire.onPress = function(){

      startDrag(this,true)

      }

       

      drawFire.onRelease = function(){

      this.stopDrag();

      checkTarget(this);

       

      }

       

      drawFire.onReleaseOutside = function(){

      this.stopDrag();

      checkTarget(this);

      }

       

      //Good Apple MC

      goodApple.onPress = function(){

      startDrag(this,true)

      }

       

      goodApple.onRelease = function(){

      this.stopDrag();

      checkTarget(this);

       

      }

       

      goodApple.onReleaseOutside = function(){

      this.stopDrag();

      checkTarget(this);

      }

       

      // Bad Apple MC

      badApple.onPress = function(){

      startDrag(this,true)

      }

       

      badApple.onRelease = function(){

      this.stopDrag();

      checkTarget(this);

       

      }

       

      badApple.onReleaseOutside = function(){

      this.stopDrag();

      checkTarget(this);

      }

       

      // Captain America Skateboard MC

      capSkate.onPress = function(){

      startDrag(this,true)

      }

       

      capSkate.onRelease = function(){

      this.stopDrag();

      checkTarget(this);

       

      }

       

      capSkate.onReleaseOutside = function(){

      this.stopDrag();

      checkTarget(this);

      }

       

      // TShirt MC

      tShirt.onPress = function(){

      startDrag(this,true)

      }

       

      tShirt.onRelease = function(){

      this.stopDrag();

      checkTarget(this);

       

      }

       

      tShirt.onReleaseOutside = function(){

      this.stopDrag();

      checkTarget(this);

      }

       

      function checkTarget(drag){

       

      if (drag.hitTest(greyCircle)) {

      drag+ gotoAndStop (54);

      drag.swapDepths(1000000);

      drag.removeMovieClip();

      } else {

      gotoAndStop (53);

      }

       

      }

        • 1. Re: Drag and Drop then Recognize
          RossRitchey Level 4

          You are already passing the object into the checkTarget function when you call it.

           

          So, the easiest method would be to check the instance name of the clip if the hitTest is true:

           

          var dragName = drag._name;

           

          switch(dragName){

               case "desCult":

               //go to frame that desCult references

               break;

               case "drawFire":

               //go to frame that drawFire references

               break;

          }

           

          (Also, a more reliable method for doing that swapDepth)

           

          drag.swapDepth(this.getNextHighestDepth()-1);

           

          This way you always swap with the highest object, and never run into problems where you have more objects than the number you put in.  I know, it is highly unlikely that you will ever have more than 1 million objects, and the Flash would probably crash at that point, but it is a guarantee.

          • 2. Re: Drag and Drop then Recognize
            goalpost95 Level 1

            so then the code would look like this?

             

            onMouseMove = function(){

            updateAfterEvent();

            }

             

            // Design And Culture MC

            desCult.onPress = function(){

            startDrag(this,true)

            }

             

            desCult.onRelease = function(){

            this.stopDrag();

            checkTarget(this);

             

            }

             

            desCult.onReleaseOutside = function(){

            this.stopDrag();

            checkTarget(this);

            }

             

            //Drawing Fire MC

            drawFire.onPress = function(){

            startDrag(this,true)

            }

             

            drawFire.onRelease = function(){

            this.stopDrag();

            checkTarget(this);

             

            }

             

            drawFire.onReleaseOutside = function(){

            this.stopDrag();

            checkTarget(this);

            }

             

            //Good Apple MC

            goodApple.onPress = function(){

            startDrag(this,true)

            }

             

            goodApple.onRelease = function(){

            this.stopDrag();

            checkTarget(this);

             

            }

             

            goodApple.onReleaseOutside = function(){

            this.stopDrag();

            checkTarget(this);

            }

             

            // Bad Apple MC

            badApple.onPress = function(){

            startDrag(this,true)

            }

             

            badApple.onRelease = function(){

            this.stopDrag();

            checkTarget(this);

             

            }

             

            badApple.onReleaseOutside = function(){

            this.stopDrag();

            checkTarget(this);

            }

             

            // Captain America Skateboard MC

            capSkate.onPress = function(){

            startDrag(this,true)

            }

             

            capSkate.onRelease = function(){

            this.stopDrag();

            checkTarget(this);

             

            }

             

            capSkate.onReleaseOutside = function(){

            this.stopDrag();

            checkTarget(this);

            }

             

            // TShirt MC

            tShirt.onPress = function(){

            startDrag(this,true)

            }

             

            tShirt.onRelease = function(){

            this.stopDrag();

            checkTarget(this);

             

            }

             

            tShirt.onReleaseOutside = function(){

            this.stopDrag();

            checkTarget(this);

            }

             

            function checkTarget(drag){

             

            var dragName = drag._name;

             

            switch(dragName){

                case "desCult":   // put in "gotoAndPlay (55 );"  here?

                 //go to frame that desCult references   

                 break;

                 case "drawFire":

                 //go to frame that drawFire references

                 break;

            }

             

            if (drag.hitTest(greyCircle)) {

            drag+ gotoAndStop (54);

            drag.swapDepths(1000000);

            drag.removeMovieClip();

            } else {

            gotoAndStop (53);

            }

             

            }

            • 3. Re: Drag and Drop then Recognize
              RossRitchey Level 4

              Yes, and you would replace the "//go to frame that desCult/drawFire references" with the script to do what you want based off of the object dropped.