     {
         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 Point();

        if (point.x < rect.left)  {  out.x = rect.left;  }
        else if (point.x > rect.right)  {  out.x = rect.right;  }
        else  {  out.x = point.x;  }

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

        return out;

        if (!out) out = new Rectangle();
        out.x = target.x + target.width * (rect.x - source.x) / source.width;
        out.y = target.y + target.height * (rect.y - source.y) / source.height;
        out.width = target.width * (rect.x + rect.width - source.x) / source.width;
        out.height = target.height * (rect.y + rect.height - source.y) / source.height;
        return out;
    }

