I think it is possible.
First you convert the displayObject in wich the design is into a byteArray wich you send to php. where you create an image using the imagecreatefromstring() function see: http://lv.php.net/imagecreatefromstring.
Example AS3
public function displayObjectToPNG(displayObject:*, scale:Number = 1):ByteArray {
var bmpData:BitmapData=new BitmapData(displayObject.width, displayObject.height, true, 0xFFFFFF);
bmpData.draw(displayObject);
var byteArray:ByteArray = PNGEncoder.encode(bmpData);
return byteArray;
}
public function encodeFile(byteArray:ByteArray):Base64Encoder {
var base64:Base64Encoder = new Base64Encoder();
base64.encodeBytes(byteArray);
return base64;
}
public function saveFile(encodedFile:Base64Encoder, scriptLocation:String):void {
var data:URLVariables = new URLVariables();
data.fileData = encodedFile;
var request:URLRequest = new URLRequest(scriptLocation);
request.method = URLRequestMethod.POST;
request.data = data;
var loader:URLLoader= new URLLoader();
loader.addEventListener(Event.COMPLETE, function(e:Event):void {fileSaved(loader);});
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatus);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioError);
_fileSavesInProgress.push(loader);
try {
loader.load(request);
} catch (e:*) {
trace("an error occured of type", e);
}
}
Implement like this (this is the code you would execute when the user clicks the button):
saveFile(encodeFile(displayObjectToPNG(sprite)), "http://www.your.domain/php/sendMail.php");
Your php file will look something like this.
<?php
$png = imagecreatefromstring(base64_decode($fileData));
function mail_attachment($to, $subject, $message, $from, $file) {
$content = chunk_split($file);
$uid = md5(uniqid(time()));
$from = str_replace(array("\r", "\n"), '', $from); // to prevent email injection
$header = "From: ".$from."\r\n"
."MIME-Version: 1.0\r\n"
."Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"
."This is a multi-part message in MIME format.\r\n"
."--".$uid."\r\n"
."Content-type:text/plain; charset=iso-8859-1\r\n"
."Content-Transfer-Encoding: 7bit\r\n\r\n"
.$message."\r\n\r\n"
."--".$uid."\r\n"
."Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"
."Content-Transfer-Encoding: base64\r\n"
."Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"
.$content."\r\n\r\n"
."--".$uid."--";
return mail($to, $subject, "", $header);
}
mail_attachment("client", "subject", "your design", "your@company.com", $png);
Note that I have not tested this but I think this will be very close if not the solution.
Good luck!
[Edit] If you want to implement this solution in one function use the following AS3 code:
public function sendSprite(sprite:Sprite, scriptLocation:String):void {
var bmpData:BitmapData=new BitmapData(sprite.width, sprite.height, true, 0xFFFFFF);
bmpData.draw(sprite);
var encodedFile:Base64Encoder = new Base64Encoder();
encodedFile.encodeBytes(PNGEncoder.encode(bmpData));
var data:URLVariables = new URLVariables();
data.fileData = encodedFile;
var request:URLRequest = new URLRequest(scriptLocation);
request.method = URLRequestMethod.POST;
request.data = data;
var loader:URLLoader= new URLLoader();
loader.addEventListener(Event.COMPLETE, spriteSend);
loader.addEventListener(Event.OPEN, traceEvent);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, traceEvent);
loader.addEventListener(IOErrorEvent.IO_ERROR, traceEvent);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, traceEvent);
loader.addEventListener(ProgressEvent.PROGRESS, traceEvent);
try {
loader.load(request);
} catch (e:*) {
trace("an error occured of type", e);
}
function traceEvent(e:*):void {
trace(e);
}
function spriteSend(e:Event):void {
trace(e, "\n sprite succesfully send \n");
}
}