8 Replies Latest reply on Jun 16, 2009 5:26 PM by kglad

    Stopdrag() help!

    javageek1212 Level 1

      Ok I have a object in an ISOmetric room I made and I made bounds that are as tall as the char so that he could not go up the wall...

      I'm wanting do do the same thing with a dynamically loaded SWF that contains and object that can be moved around and stuff,

      well I have tried to make it so that when it collides with the bounds I made for the man it would stopdrag() but it won't!

       

      Is there another way I could do this or a way to impove the current way???

       

       

      -javageek

        • 1. Re: Stopdrag() help!
          kglad Adobe Community Professional & MVP

          why is your stopDrag() not working?

          • 2. Re: Stopdrag() help!
            javageek1212 Level 1

            Well im trying to stop the drag from another movieclip once it hittest the bounds on the _root

            • 3. Re: Stopdrag() help!
              christoon_ca Level 1

              could you post your script so we have a clearer understanding?

              • 4. Re: Stopdrag() help!
                javageek1212 Level 1

                Well I can't really post the script cause it's broken up but I will give you an example:

                 

                I have a movieclip on the _root called wall and then I have a clip called box.

                I want the box to startdrag() when I press it but I already know how to startdrag()!

                The wall when it detects collision with the box I want it to stopdrag() the code for startdrag() is on the box clip

                and the hittest is going to be on the wall clip.

                How do I make it stopdrag from the wall clip?

                 

                 

                -javageek

                • 5. Re: Stopdrag() help!
                  christoon_ca Level 1

                  from what I gather you need something like this:

                   

                  box.onPress = function(){
                  startDrag(this,true
                  ,#,#,#,#)
                  }

                   

                  box.onReleaseOutside = function(){
                  this.stopDrag();
                  }

                   

                  or this:

                   

                  function checkTarget(drag) {

                        if (drag.hitTest(wall) {
                             stopDrag()

                       }
                  };

                   

                  I learned some good basic drag stuff from this tutorial

                  • 6. Re: Stopdrag() help!
                    javageek1212 Level 1

                    How do I implement and use those?

                     

                     

                     

                     

                     

                     

                    -javageek

                    • 7. Re: Stopdrag() help!
                      christoon_ca Level 1

                      I would highly recommend checking out that tut link in my last post.

                       

                       

                      so this would be sitting on frame 1 of main timeline. "box" refers to your drag object.

                       

                      //after startDrag is your target (your box, or "this" can be used), then whether the target drags from click point or center (true/false) lastly: the constraining coordinates which read "left, top, right, bottom" (in pixels)

                       

                      box.onPress = function(){
                      startDrag(this,true
                      ,#,#,#,#)
                      }

                       

                       

                      //this says that when you release outside the coordinates you set, the drag action stops.

                       

                      box.onReleaseOutside = function(){
                      this.stopDrag();
                      }

                       

                      does that help?

                      • 8. Re: Stopdrag() help!
                        kglad Adobe Community Professional & MVP

                        executing stopDrag() will stop the dragging.  there's no way to goof that up because no path/name is needed.

                         

                        so you need to detect when you wall is hit.  ie, start a loop (or use one that's already running), check for the hittest and, if positive, execute stopDrag()