A quick-and-dirty method to save display objects as PNGs with transparency. The PNGEncoder class from the as3corelib is required.

AS3:

[as3]
package {

import com.adobe.images.PNGEncoder;

import flash.display.BitmapData;
import flash.display.DisplayObject;

import flash.net.URLLoader;
import flash.net.URLRequestHeader;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.net.URLRequest;

import flash.utils.ByteArray;

public class PNGWriter extends URLLoader {

public static const URL:String = “path/to/png-writer.php”;

public function PNGWriter(target:DisplayObject):void{

var source:BitmapData = new BitmapData(target.width, target.height, true, 0x00000000);
source.draw(target);

var stream:ByteArray = PNGEncoder.encode(source);

var header:URLRequestHeader = new URLRequestHeader(“Content-type”, “application/octet-stream”);

var request:URLRequest = new URLRequest(PNGWriter.URL);
request.method = URLRequestMethod.POST;
request.data = stream;
request.requestHeaders.push(header);

load(request);

}
}
}
[/as3]

PHP: