[mx] Snap a shape to another Object

I need some help on a game that I am making. It is basically a puzzle game like a jigsaw. You have 30 pieces, 15 one shape and 15 another, to play with and you need to fill a certain shape.

Where I am at the moment:
o 2 Buttons create the shapes
o the shapes can be rotated whilst pressing the ‘Ctrl’ key

What I need is for the shapes to snap to each other. So when you put a shape within 5 or so pixels of another they snap to the edge coordinates of that shape.

Dose anyone even know the theory behind that or if in fact it can be done?? I have uploaded it cos I think my explanation of what I need is a bit crap.

cheers
C:-)