 
     public override function set scale9Grid(innerRectangle:Rectangle):void
     {
-        _scale9Grid = innerRectangle;
+        _scale9Grid = innerRectangle && _bitmapData ?
+              clampRect(innerRectangle, _bitmapData.rect)
+            : innerRectangle;
         uvsNeedRecalc = vertsNeedRecalc = true;
         invalidate();
     }


    public function set bitmapData(new_bitmapData:BitmapData):void
    {
        uvsNeedRecalc = vertsNeedRecalc = !bitmapsSameSize(_bitmapData, new_bitmapData);
        _bitmapData = new_bitmapData;
        invalidate();
    }


        return _indicesCorners;
    }

    private static function clampRect(rect:Rectangle, outer:Rectangle):Rectangle
    {
        var newLeft:Number = clamp(rect.left, outer.left, outer.right);
        var newRight:Number = clamp(rect.right, outer.left, outer.right);
        var newTop:Number = clamp(rect.top, outer.top, outer.bottom);
        var newBottom:Number = clamp(rect.bottom, outer.top, outer.bottom);

        return new Rectangle(newLeft, newTop, newRight - newLeft, newBottom - newTop);
    }

    private static function clamp(v:Number, min:Number, max:Number):Number
    {
        return v < min ? min :
               v > max ? max :
                         v;
    }
}
}
