views:

394

answers:

3

Can you export a drawing made in flash as a transparent png in actionscript I know you can do it as a jpg with a white background but can you export the transparency?

+1  A: 

Yes. Check out PNGEncoder in as3corelib (http://code.google.com/p/as3corelib/). Just take a snapshot of the MovieClip / Sprite that contains the drawing (make sure you create the BitmapData as transparent) and pass it to the encoder.

Juan Pablo Califano
A: 

If you've just drawn the image in Flash and want it as a png then you don't need to export with ActionScript, just go:

File > Export > Export Image > Save as type > .png

Iain
the OP doesn't specify but I think he means programatically at runtime not during author time, but I could be wrong.
John Isaacks
A: 

I built a way to do this myself once. First I used bitmapdata.draw to convert it into a bitmap then looped through each pixel and got its value via getPixel32() (getPixel32 includes transparency getPixel() does not) and stored it into an array. Then I sent the very long array to PHP and used a loop to go through the array and reconstruct the image. Its not very efficient but no one at the time could tell me any other way to do so, and I was proud I figured out a way on my own.

John Isaacks