Hi,
I have this code on a frame in Air file using Flash CS3:
var spBoard:Sprite=new Sprite();
this.addChild(spBoard);
var shDrawing:Shape=new Shape();
spBoard.addChild(shDrawing);
shDrawing.graphics.beginFill(0xFFCC00);
shDrawing.graphics.lineStyle(1, 0x666666);
shDrawing.graphics.drawCircle(100, 100, 300);
shDrawing.graphics.endFill();
//==================================
//Save PNG:
import com.adobe.images.PNGEncoder;
import flash.filesystem.*;
btnSave.addEventListener(MouseEvent.CLICK, btnSave_CLICK);
function btnSave_CLICK(e:MouseEvent):void {
var BMP:BitmapData=new BitmapData(500,500);
BMP.draw(shDrawing);
var BA:ByteArray;
BA=PNGEncoder.encode(BMP);
var file= File.desktopDirectory.resolvePath(“Image1.png”);
var filestream1:FileStream=new FileStream();
filestream1.open(file,FileMode.WRITE);
filestream1.writeByte(BA);
filestream1.close();
}
and the line (filestream1.writeByte(BA)
generate this error:
1067: Implicit coercion of a value of type flash.utils:ByteArray to an unrelated type int.
anybody can make it work?
thanks a lot.