Senocular's TransformTool Boundary Restriction?

I want to impelement a boundary restriction in my use of Senocular’s TransformTool (as in, user is unable to drag the sprite outside of a set rectangle).

I inserted a checkBoundaries function in the TransformTool class’s calculateTransform function immediately before the call to the restrict function.

My checkBoundaries function looks like:


 private function checkBoundaries() {
   // check boundaries
 
   if(_toolTransform.tx < boundaryLeft) {
    _toolTransform.tx = boundaryLeft;
   }
 
   if (_toolTransform.tx + _target.width> boundaryRight) {
    _toolTransform.tx = boundaryRight - _target.width;
   }
 
   if (_toolTransform.ty < boundaryTop) {
    _toolTransform.ty = boundaryTop;
   }
 
   if (_toolTransform.ty + _target.height > boundaryBottom) {
    _toolTransform.ty = boundaryBottom - _target.height;
   }
  }

This code works fine when I’m just moving the image around the stage. However, when I resize the clip and try and resize bigger than the stage, things go really screwy. Specifically, when the registration point is anything different than the top left corner.

Anybody have any ideas on how to implement such a boundary restriction?
I could force the registration point to be in the top left, but I’d rather not.