获得舞台的一部分?

ebl*_*lek 0 flash actionscript-3

我正在使用jpeg编码器脚本.在脚本示例中,影片剪辑将转换为jpeg.不同,我想转换舞台,但只有一部分,如x:320-500,y:0-600.可能吗?

function createJPG(m:MovieClip, quality:Number, fileName:String)
{
    var jpgSource:BitmapData = new BitmapData (m.width, m.height);
    jpgSource.draw(m);

    var jpgEncoder:JPGEncoder = new JPGEncoder(quality);
    var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);     
    ...
}

create(partOfStage,90,"name");
Run Code Online (Sandbox Code Playgroud)

Jua*_*ano 5

已发布的答案可能会有效,但有一种更简单的方法.Matrix是你的朋友.

这也使用了更少的资源:只有一个BitmapData,只有它需要的大(即,与裁剪区域一样大):

//  x:320-500, y:0-600
//  --> x: 320, y: 0, width: (500-320), height: (600 - 0)
var cropArea:Rectangle = new Rectangle(320,0,180,600);
var mat:Matrix = new Matrix();
mat.translate(-cropArea.x,-cropArea.y);
var snapshot:BitmapData = new BitmapData(cropArea.width,cropArea.height);
snapshot.draw(stage,mat);
Run Code Online (Sandbox Code Playgroud)

在我看来,你可以避免使用矩形,但我会留下它,因为它更具可读性.