我们知道使用文件引用保存方法我们可以将组件保存为flex 3中的图像,但我使用的是flex 3.0版本,我没有在文件引用类中获取save方法。它可以从flex 3.4.0开始使用。我们是否有任何其他选项可以使用flex builder IDE在Flex 3.0编译器中对组件进行映像?
提前致谢
答案 0 :(得分:0)
如果这种情况允许使用HTML5,则可能。
public function capturePage(): void
{
var bmp:BitmapData = new BitmapData(this.width, this.height);
bmp.draw(this, new Matrix());
// convert to JPEG.
var fileData:ByteArray = new JPEGEncoder().encode(bmp);
var base64: Base64Encoder = new Base64Encoder();
base64.encodeBytes(fileData);
ExternalInterface.call("saveAsImage", "data:image/jpeg;base64,"+base64.toString());
}
index.template.html
<title>${title}</title>
<script language="JavaScript" type="text/javascript">
function saveAsImage(value)
{
// open new window. You will be able to save as image.
window.open(value);
// or use HTML5 FileWriter API here.
}
</script>
<script src="AC_OETags.js" language="javascript"></script>
答案 1 :(得分:0)
private function doSave():void
{
var bmp:BitmapData = new BitmapData(canvas.width,canvas.height);
bmp.draw(canvas,new Matrix());
var filedate:ByteArray = new JPEGEncoder().encode(bmp);
var uploadURL:URLRequest = new URLRequest();
uploadURL.url = parentApplication.ServerUrl+"...../imageupload.php?fileName="+yourfilename;
uploadURL.contentType = 'application/octet-stream';
uploadURL.method = URLRequestMethod.POST;
uploadURL.data = filedate;
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, completeHandler);
urlLoader.load(uploadURL);
}
PHP文件:imageupload.php
<?php
$fileName = $_REQUEST['fileName'] . ".jpeg";
$fp = fopen( "../tempfolder/".$fileName, 'wb' );
fwrite( $fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ] );
fclose( $fp );
?>