12 Replies Latest reply on Sep 26, 2008 5:11 AM by Newsgroup_User

    Drag and Drop, switch piece puzzle problem

    Frederic Jan Level 1

      I am trying to create a puzzle that has 18 pieces which the user can drag from on piece to the other. When the puzzle/game starts, the pieces will placed on the stage in random order.
      When the user drags one piece over another, the 2 pieces will be switched.
      This is done technically when the 'hit area' (a smaller mc inside of the main 'piece' mc) from one piece is over another.
      When the user releases a piece, a 'switch' function will be called. This function uses x and y coordinates which are defined outside the function.

      At this moment some pieces actually change location, others simply don't. They go back to the old location, or don't switch with another piece. I guess it has to do with the x- and y- vars of certain peices which cannot be defined correctly.

      The intention is that a user can drag and drop a puzzle piece over another. When the user releases the piece, the 2 pieces will switch location. If the dragged piece is not over another piece, it will go back to it's old location.
      I hope someone can help me.

      See my Example
      you'll see the only some piece actually work correctly.
      I hope someone can help