     {
         if (!out) out = new Rectangle();
 
-        var r:Number = rect.right, b:Number = rect.bottom;
+        var r:Number = rect.x + rect.width;
+        var b:Number = rect.y + rect.height;
 
         out.x = Math.floor(rect.x);
         out.y = Math.floor(rect.y);

    {
        if (!out) out = new Rectangle();

        var r:Number = rect.right, b:Number = rect.bottom;

        out.x = Math.ceil(rect.x);
        out.y = Math.ceil(rect.y);

    {
        if (!out) out = new Point();

        if (point.x < rect.x)  {  out.x = rect.x;  }
        else if (point.x > rect.x + rect.width)  {  out.x = rect.x + rect.width;  }
        else  {  out.x = point.x;  }

        if (point.y < rect.top)  {  out.y = rect.top;  }
        else if (point.y > rect.y + rect.height)  {  out.y = rect.y + rect.height;  }
        else  {  out.y = point.y;  }

        return out;
