3 Replies Latest reply on Aug 16, 2009 8:01 AM by kglad

    hitTest and draggable MCs

    prodigalmaster Level 2

      **These codes are in the draggable MC: fish1_drag

       

      Hi, this is my code:

       

      onClipEvent (enterFrame) {
          this.onPress = function() {
              startDrag(this);
          };

       

          _root.UI1_mc.UI1_mc2.inv_mc.ISpace1.onEnterFrame = function() {
              if (this.hitTest(fish1_drag)) {
                  stopDrag();
              } else {
              }
          };
      }

       

      I keep jumbling it up so that one thing works but the other doesnt. But basicly I need it so that when I drag fish1_drag (instance name) over ISpace1 (which is within many MCs : _root.UI1_mc.UI1_mc2.inv_mc.ISpace1 but opens up so you can drag it over it) for it the drop on the ISpace1.

       

      I have another MC in the library and il get that the attach to the ISpace1 but what im finding difficult is just being able to drag the fish1_drag over the ISpace1 and releasing.

       

      Here is some other reandom code that I have in a comment on my AC panel:

       

      /*

                  this.onRelease = function() {
                      stopDrag();
                      _root.UI1_mc.UI1_mc2.inv_mc.ISpace1.attachMovie("fish1_mc","attached1",this.getNextHighes tDepth());
                      _root.invCount += 1;
                      updateAfterEvent();  // I probly dont need this updateAfterEvent. but its there anyway.
                  };

      */

      Thanks please help, hope you understand my jibberish speech.

        • 1. Re: hitTest and draggable MCs
          kglad Adobe Community Professional & MVP

          use:


           



              fish1_drag.onPress = function() {
                 this.startDrag();
              };

           

              _root.UI1_mc.UI1_mc2.inv_mc.ISpace1.onEnterFrame = function() {
                  if (this.hitTest(fish1_drag)) {

          delete this.onEnterFrame;
                      stopDrag();
                  }
              };

          • 2. Re: hitTest and draggable MCs
            prodigalmaster Level 2

            OK thanks but... as my timelines are a bit messy it probly isnt letting the code wrk properly but.. it now cant even drag.

             

            onClipEvent (enterFrame) {
                fish1_drag.onPress = function() {
                    this.startDrag();
                };
                _root.UI1_mc.UI1_mc2.inv_mc.ISpace1.onEnterFrame = function() {
                    if (this.hitTest(fish1_drag)) {
                        delete this.onEnterFrame;
                        stopDrag();
                    }
                };
            }

            doesnt even drag.

             

            I tried it with fish1_drag being: this

            and fish1_drag_mc

            and I added a linkage of fish1_drag but nothing worked, its probly because the inventory is nested weirdly, il keep trying.

            • 3. Re: hitTest and draggable MCs
              kglad Adobe Community Professional & MVP

              the code i gave should be attached to the timeline that contains fish1_drag and your code should be removed.  in particular, there should be no code attached to a movieclip.