Is it possible to make the p1x and p1y variables of the objects or is there any other way to create a reference between the objects and their desired pin-position? if so you could just make a function.
on object dropped call function"CheckDistance" with parameters (object.x,object.y,object.pinlocationx,object.pinlocationy)
on function "CheckDistance"
(subevent) - Sytem compare values : distance(param(1),param(2),param(3),(param(4)) < 22
and add your actions.