4 Replies Latest reply on Apr 19, 2006 5:24 PM by discb

    Drgging Blocks, No Overlap (Best Way)

      Hi, I have blocks with letters on them (Movie Clips) and I want to be able to slide them up, down and sideways in order to make a word, But I don't want them to overlap each other as I'm sliding them. they are named, LetA...LetB...LetC and so on untill LetZ.
      Sort of like you need to move one out of the way to slide another in it's place

      I have a drag action on all blocks but right now I can drag them all over the place, even over the others (which I don't want)

      Can anyone help get me started with code for one of the blocks.

      I have tried searching Hittest, Collission, Overlapping and Dragging but I can't find anything that I can (or know how to) modify in order to make this happen.

        • 1. Drgging Blocks, No Overlap (Best Way)
          hitTest is all you need.
          however you will have to make your own equation to calc the limit of dragging.
          the limit is everchanging due to it position corressponding to the other blocks.

          if i guess what you're trying to do correctly. you only need the check to see if the block has a free space up/down/left/right.
          then add the drag limit param as required.

          edit: my_mc.startDrag(lockCenter,top,left,right,bottom);
          • 2. Drgging Blocks, No Overlap (Best Way)
            discb Level 1
            Thanks for your reply shyaway
            There will be 26 blocks (the Alphabet) and one empty spot big enough for a block to slide into.

            So as you said ( "you only need the check to see if the block has a free space up/down/left/right" )

            Would I use this - "my_mc.startDrag(lockCenter,top,left,right,bottom); "
            And If so would I put a hittest code before It. ?

            I just got Flash 8 and I know I need to read a few tuts but the help section in flash assumes that I allready know some coding. I'm having a bit of trouble understang some of It)
            For instance It tells me to add this code to drag a Movie Clip
            garbage_mc.onPress = function() {

            "garbage_mc.onRelease = function() {
            this.stopDrag(); "
            Which I changed garbage_mc to LetA

            And all I got Is errors, I had to change It to this In order for it to work
            " on (press) {
            on (release) {
            } "

            Anyway I'd appriciate It If I can get help with making one of the blocks working and then maybe I'd pickup on how to do the others
            • 3. Re: Drgging Blocks, No Overlap (Best Way)
              shyaway Level 1
              many ways to approach of course.
              however, let's stick with one we are already on.
              so you have 28 space for 27 blocks.
              using hitTest, you can detect if the space is occupied.

              once that's done. you will know whether the current block is allowed to move in 1 of the direction.
              that is where the startDrag comes in. use the left/top/right/bottom param of start drag to limit its movement.

              if you're unfamiliar with hitTest and/or startDrag. make sure you play around with each separately first and see what they do before trying to combine them. walk then run.
              • 4. Re: Drgging Blocks, No Overlap (Best Way)
                discb Level 1
                Ok, let me go back and ask my question again inanother way because this is not getting me anywhere.

                I have a box (movie Clip) which I want to drag, BUT If It hits another box (Movie Clip) I want It to be able to go around It and not through It.
                I am able to drag my boxA but at the moment It goes through everything

                Can someone help me with a code that when boxA hits boxB It will at least Stop ? If know one knows how to make it go another route?

                and then maybe I can work from there.