我想将一个区域从movieclip复制到形状图形,这可能吗?
另外,有什么建议的方法来清除bitmapdata?
答案 0 :(得分:0)
您可以尝试这样
//go to target frame
mc.gotoAndStop(1);
//the area you want to draw
var area:Rectange = new Rectange(50, 60, 100, 200);
if (mc.width != 0 && mc.height != 0) {
//draw the mc on the target frame
var temp:BitmapData = new BitmapData(mc.width, mc.height, true, 0x00000000);
temp.draw(mc);
//target area bitmapdata
var targetBD:BitmapData = new Bitmapdata(area.width, area.height, true, 0x00000000);
targetBD.copyPixels(temp, area, new Point(0, 0));
//draw to shape
shape.graphics.beginBitmapFill(targetBD);
shape.graphics.drawRect(0, 0, area.width, area.height);
shape.graphics.endFill();
}
您可以在BitmapData上调用dispose方法来清理位图数据,它将释放用于存储BitmapData对象的内存。