var cropedImage:BitmapData = new BitmapData(positionImage.width, positionImage.height);
var matrix:Matrix = new Matrix;
var matrixXY:Point = new Point();
var smooth:Boolean = false;
var bounds1 = positionImageMasking.getRect(this);
var bounds2 = positionImage.getRect(this);
matrixXY.x = (bounds1.x - bounds2.x)/positionImageMasking.scaleX;
matrixXY.y = (bounds1.y - bounds2.y)/positionImageMasking.scaleY;
trace("matrixXY.x = " + matrixXY.x);
matrix.tx = matrixXY.x;
matrix.ty = matrixXY.y;
matrix.scale(positionImageMasking.scaleX, positionImageMasking.scaleY);
//matrix.rotate(Math.PI/14);
if (positionImageMasking.scaleX != 1)
{
smooth = true;
}
cropedImage.draw(loadedBitmap.bitmapData, matrix,null,null,null,smooth);

var mc:MovieClip = new MovieClip();
mc.graphics.beginBitmapFill(cropedImage);
mc.graphics.drawRect(0, 0, positionImage.width, positionImage.height);
mc.graphics.endFill();
addChild(mc);