# PNG Encoder Problem

**URL:** <https://forum.kirupa.com/t/png-encoder-problem/266482>\
**Category:** flash\
**Created:** [July 21, 2008, 9:40am UTC](https://forum.kirupa.com/t/png-encoder-problem/266482 "2008-07-21T09:40:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![emadzedan](https://avatars.discourse-cdn.com/v4/letter/e/eada6e/32.png) [@emadzedan](https://forum.kirupa.com/u/emadzedan)\
**Post date:** [July 21, 2008, 9:40am UTC](https://forum.kirupa.com/t/png-encoder-problem/266482/1 "2008-07-21T09:40:45Z")

</div>

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.
