Hi,
i am trying to save a movieclip as jpg image using JPGEncoder using following code,
import com.adobe.images.JPGEncoder;
export_btn.addEventListener (MouseEvent.CLICK, doClick);
function doClick (eve:MouseEvent):void
{
var bmData:BitmapData = new BitmapData(export_mc.width+10,export_mc.height+10);
bmData.draw (export_mc);
var jpgEncoder:JPGEncoder = new JPGEncoder(85);
var jpgStream:ByteArray = ByteArray(jpgEncoder.encode(bmData));
var bm:Bitmap = new Bitmap(bmData);
//addChild(bm);
var header:URLRequestHeader = new URLRequestHeader("Content-type","application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest("jpg-ecoder-download.php?name=sketch.jpg");
jpgURLRequest.requestHeaders.push (header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
var _tempLoader:URLLoader = new URLLoader();
//_tempLoader.load(jpgURLRequest);
navigateToURL (jpgURLRequest, "_blank");
}
it works fine every other browser but not with FireFox, can some one tell me whats the problem.
following code is used in pg-ecoder-download.php…
<?php
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
// get bytearray
$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
// add headers for download dialog-box
header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename=".$_GET['name']);
echo $jpg;
}
else
{
echo "code does not works with firefox.....!";
}
?>