private function btnPlus_ClickHandler(e:MouseEvent):void{
if(col<8){
col++;
}
txtTileNum.text=col+"X"+col;
}
private function btnMinus_ClickHandler(e:MouseEvent):void{
if(col>3){
col--;
}
txtTileNum.text=col+"X"+col;
}
private function dragTile(e:MouseEvent):void{
var tile:Tile=Tile(e.currentTarget);
if(tile.dragable){
scene.setChildIndex(tile,scene.numChildren-1);
tile.startDrag();
}
}
private function stopDragTile(e:MouseEvent):void{
var tile:Tile=Tile(e.currentTarget);
tile.stopDrag();
var targetX:Number=tile.index%col*tileWidth+tileWidth/2+rectCanvas.x;
var targetY:Number=Math.floor(tile.index/col)*tileHeight+tileHeight/2+rectCanvas.y;
var targetPoint:Point=new Point(targetX,targetY);
var mousePoint:Point=new Point(e.stageX,e.stageY);
判断以上两个位置是否足够接近,如果距离小于碎片宽度的一半,表示释放位置正确
if(Point.distance(mousePoint,targetPoint)<tileWidth/2){