代码如下:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
	<s:layout>
		<s:BasicLayout/>
	</s:layout>

	<fx:Script>
		<![CDATA[
			import mx.graphics.ImageSnapshot;
			protected function button1_clickHandler(event:MouseEvent):void
			{
				var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(text1); 
				var imageByteArray:ByteArray = imageSnap.data as ByteArray; 
				image1.load(imageByteArray);
			}
		]]>
	</fx:Script>

	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
	</fx:Declarations>
	<s:TextArea />
	<mx:Image />
	<s:Button x="80" y="27" label="截图" click="button1_clickHandler(event)"/>
</s:Application>

 

在TextArea组件中输入相应的内容,然后点击“截图”按钮,通过ImageSnapshot类的功能,可以把组件的快照保存下来,通过data属性可以获取快照ByteArray类型的数据,我这里把截图放到Image组件里来显示了。这是一个辅助性的功能,说不定什么时候就可以派上用场哦。

相关文章:

  • 2021-08-29
  • 2021-10-14
  • 2021-11-13
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-02
  • 2022-12-23
  • 2021-07-03
  • 2022-01-05
  • 2021-12-27
  • 2022-12-23
相关资源
相似解决方案