[code]
var fileRef:FileReference=new FileReference();//用于保存文件
var _encoder:JPGEncoder=new JPGEncoder(80);//用于编码位图
var bitmapData:BitmapData=new BitmapData(ww,hh);
bitmapData.draw(mc);//得到位图
var Data:ByteArray=_encoder.encode(bitmapData);//二进制数据
fileRef.save(Data,defaultFileName);
[/code]
~~~~~~~
搞个函数封装下,hoho
[code]
import com.adobe.images.JPGEncoder;
import com.adobe.images.PNGEncoder;
function saveImg():void {
var saveFile:FileReference = new FileReference();
saveFile.save(image_binary(), "1.png" );
}
function image_binary() : ByteArray {
//tr.ace('Saving image :: image_binary()');
var pngSource:BitmapData = new BitmapData(this.width, this.height);
pngSource.draw(this);
//var jpge:JPGEncoder = new JPGEncoder(100);
//return jpge.encode(pngSource);
return PNGEncoder.encode(pngSource);
}
[/code]