Download the FLA file to see how this is done.
All the code is on a button inside the jigsaw piece movie clip. The instance of the jigsaw piece is called 'piece1' and the instance of the drop area is called 'drop1'. The variable 'piece1correct' is used to store the value TRUE or FALSE.
on (press){
// drag the jigsaw piece
_root.piece1.startDrag();
}
on (release){
// stop dragging the jigsaw piece
_root.piece1.stopDrag();
// if the jigsaw piece is dropped on the drop area, snap it into position and set piece1correct to TRUE
if (eval(_root.piece1._droptarget) == _root.drop1) {
_root.piece1._x=_root.drop1._x;
_root.piece1._y=_root.drop1._y;
_root.piece1correct="True";
}else{
// if the jigsaw piece is NOT dropped on the drop area, set piece1correct to FALSE
// this is useful if the piece is dragged into position and later moved off
_root.piece1correct="False";
}
}
|