Flash 从精灵中的遮罩下方保存图像

Flash 从精灵中的遮罩下方保存图像,flash,actionscript-3,Flash,Actionscript 3,我有一个sprite对象,它加载了一个自定义形状,用作遮罩,以便从加载了加载对象的图像中剪切自定义形状-加载对象(加载对象)和形状(线条)对象都是sprite对象的子对象-我添加了代码以从掩码下保存图像,但是当调用save函数时,不会保存任何内容,也不会引发任何错误 function save(evt:MouseEvent):void{ //Create random number from current date/time to name image created var

我有一个sprite对象,它加载了一个自定义形状,用作遮罩,以便从加载了加载对象的图像中剪切自定义形状-加载对象(加载对象)和形状(线条)对象都是sprite对象的子对象-我添加了代码以从掩码下保存图像,但是当调用save函数时,不会保存任何内容,也不会引发任何错误

function save(evt:MouseEvent):void{
    //Create random number from current date/time to name image created
    var imgID:Number= new Date().getTime()
    //Matrix to holder the area to be cropped
    var maskRect = loada.mask.getBounds(lines);
    //Matrix of image to be cropped
    var imgMatrix= loada.mask.transform.matrix;
    //Cropped image
    var myCroppedImage:Bitmap = cropImage(maskRect, imgMatrix, loada.mask.width, loada.mask.height, loada.mask );
    //Get new matrix of cropped image
    var m:Matrix = myCroppedImage.transform.matrix;
    var urlLoader:URLLoader = new URLLoader();
    //Set jpg quality of the image to be export 1-100
    var myEncoder:JPGEncoder = new JPGEncoder(80);
    //Create jpg to be exported
    var jpgSource:BitmapData = new BitmapData (loada.mask.width, loada.mask.height);
    jpgSource.draw(myCroppedImage, m);
    //Create byte array to hold jpg data
    var byteArray:ByteArray = myEncoder.encode(jpgSource);
    var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
    trace(imgID);
    //Send image to the server to be saved
    var saveJPG:URLRequest = new URLRequest("save_image.php?r="+imgID);
    saveJPG.requestHeaders.push(header);
    saveJPG.method = URLRequestMethod.POST;
    saveJPG.data = byteArray; 
    trace(saveJPG);
}

//Crop image
function cropImage( rect, matrix, _width:Number, _height:Number, displayObject:DisplayObject):Bitmap {
    //Create cropped image
    var croppedBitmap:Bitmap = new Bitmap( new BitmapData( _width, _height ), PixelSnapping.ALWAYS, true );
    croppedBitmap.bitmapData.draw(displayObject, matrix , null, null, rect, true );
    return croppedBitmap;
}

从您在此处发布的内容来看,您似乎没有调用“加载”函数:

urlLoader.load(saveJPG);

如果您将“myCroppedImage”添加到舞台,您能看到它吗?