Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-21-2008, 09:36 AM   #1
emadzedan
Registered User
 
Join Date: Jul 2008
Posts: 7
Exclamation PNG Encoder Problem

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 lline (filestream1.writeByte(BA)

genarate 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.
emadzedan is offline   Reply With Quote
Old 07-21-2008, 09:38 AM   #2
emadzedan
Registered User
 
Join Date: Jul 2008
Posts: 7
Exclamation PNG Encoder Problem

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.
emadzedan is offline   Reply With Quote
Old 07-21-2008, 11:47 AM   #3
emadzedan
Registered User
 
Join Date: Jul 2008
Posts: 7
Default

I knew the problem, it is:
filestream1.writeBytes(BA);
emadzedan is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash 8 Video Encoder arpace ActionScript 2.0 21 12-18-2010 11:26 AM
Flash 8 Video Encoder Not Working on OS X? gluefreak Flash 8 General Questions 10 03-14-2007 07:20 PM
Some Flash Video Converter Tools Compare terry117 Detention 7 05-18-2006 02:08 AM
Problem with loading unloading clips and dynamic text sah302 ActionScript 1.0 (and below) 1 01-06-2006 05:19 PM


All times are GMT. The time now is 12:45 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.