Inside the for each
loop you can check to see whether or not the result point's distance is less than 20 pixels, and only snap the current clip to the result point if it is. Here's an example:
...
function SnapEvent(event:MouseEvent) {
//// the clip we're dragging////
var referencePoint:Point = new Point(currentClip.x, currentClip.y);
var resultPoints:Array = PointTester.findClosest(referencePoint, pointList, 1);
////returns nearest "mat" and snaps current clip to it////
for each(var result:Object in resultPoints) {
if(result.distance < 20){ //if the result point's distance is less than 20 pixels away from the current clip
currentClip.x=result.point.x; // snap the current clips position
currentClip.y=result.point.y;
var posOfMat:int = pointList.indexOf(result.point);
trace("index: "+pointList[posOfMat]);
spliced.push(pointList[posOfMat]);
pointList.splice(posOfMat,1);
//trace("spliced: "+spliced);
trace("length: "+pointList.length);
}
//otherwise do nothing
}
//trace("result: "+result.point);
trace("full spliced: "+spliced.length);
}
I hope this helps.