在Flex 3的DisplayObject快照快照、Flex、DisplayObject

由网友(落寞少年)分享简介:我要创建Flex中的可视化编辑器,需要让用户导出thier项目到图像格式。但我有一个问题:在画布的大小是固定的,当用户添加元素,这就是这些大小一些滚动条添加的。而用户继续参与该项目。但是当他想利用画布快照,他刚刚得到的可见部分加时赛的滚动条在画布上。如何获得全尺寸的画布图像?我发现的唯一的解决办法是检查帆布子对象的位置...

我要创建Flex中的可视化编辑器,需要让用户导出thier项目到图像格式。但我有一个问题:在画布的大小是固定的,当用户添加元素,这就是这些大小一些滚动条添加的。而用户继续参与该项目。但是当他想利用画布快照,他刚刚得到的可见部分加时赛的滚动条在画布上。如何获得全尺寸的画布图像?

我发现的唯一的解决办法是检查帆布子对象的位置和大小,并rezise它适合他们。然后采取捕捉和调整回来。但是,hmmmm ...太复杂了,我认为。有一些简单的方法?

 < XML版本=1.0编码=UTF-8&GT?;
< MX:应用的xmlns:MX =htt​​p://www.adobe.com/2006/mxml布局=垂直>
< MX:脚本>
<![CDATA [
进口mx.graphics.ImageSnapshot;

私有函数SnapshotButtonHandler():无效
{
VAR快照:将ImageSnapshot = ImageSnapshot.captureImage(AppCanvas);
var文件:的FileReference =新的FileReference();
file.save(snapshot.datacanvas.png);
}
]]≥
< / MX:脚本>
< MX:帆布ID =AppCanvasWIDTH =800HEIGHT =300的backgroundColor =0XFFFFFF>
< MX:盒子X =750Y =100宽度=100HEIGHT =100的backgroundColor =0xCCCCCC/>
< / MX:帆布>
< MX:按钮的ID =SnapshotButton标签=拍摄快照点击=SnapshotButtonHandler()/>
< / MX:用途>
 

解决方案

克里希纳:确保你的目标的Flash Player 10中您的构建路径。

i'm creating a visual editor in flex and need to let users export thier projects into Image format. But i have one problem: size of the canvas is fixed and when user add element which is out of these sizes some scroll bars added. And user continue working on the project. but when he want to take snapshot of the canvas he just get the visible part ot the canvas with scrollbars. how to get image of the fullsize canvas?

RIA领域几种数据传输形式的性能比较 Flex AMF最快

The only solution i found is to check the positions and sizes of canvas child objects and rezise it to fit them. then take snap and resize back. But it hmmmm... too complicated i think. Is there some "easy methods"?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
	<![CDATA[
		import mx.graphics.ImageSnapshot;

		private function SnapshotButtonHandler():void
		{
			var snapshot:ImageSnapshot = ImageSnapshot.captureImage(AppCanvas);
			var file:FileReference = new FileReference();
			file.save(snapshot.data, "canvas.png");
		}
	]]>
</mx:Script>
<mx:Canvas id="AppCanvas" width="800" height="300" backgroundColor="0xFFFFFF">
	<mx:Box x="750" y="100" width="100" height="100" backgroundColor="0xCCCCCC" />
</mx:Canvas>
<mx:Button id="SnapshotButton" label="take snapshot" click="SnapshotButtonHandler()" />	
</mx:Application>

解决方案

krishna: make sure you're targeting flash player 10 in your build path.

阅读全文

相关推荐

最新文章