存取flex屏幕快照

所属分类: 网页制作 / Flash 阅读数: 1702
收藏 0 赞 0 分享
<?xml version="1.0" encoding="utf-8"?>
<!-- http://yecon.blog.hexun.com/31031093_d.html -->
<Application name="FileReference_save_test"
xmlns="http://ns.adobe.com/mxml/2009"
xmlns:mx="library:adobe/flex/halo"
xmlns:net="flash.net.*"
layout="flex.layout.BasicLayout"
creationComplete="init();">
<Script>
<![CDATA[
private function init():void {
textArea.text = describeType(FileReference).toXMLString();
}
private function btn_click(evt:MouseEvent):void {
fileReference.save(textArea.text, "describeType.txt");
}
]]>
</Script>
<Declarations>
<net:FileReference id="fileReference" />
</Declarations>
<mx:Panel id="panel"
width="500"
height="300"
verticalCenter="0"
horizontalCenter="0">
<mx:TextArea id="textArea"
editable="true"
width="100%"
height="100%" />
<mx:ControlBar horizontalAlign="right">
<Button id="btn"
label="Save Text"
click="btn_click(event);" />
</mx:ControlBar>
</mx:Panel>
</Application>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//也可以通过XML对象直接使用FileReference类的save()方法:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://yecon.blog.hexun.com/31031093_d.html -->
<Application name="FileReference_save_test"
xmlns="http://ns.adobe.com/mxml/2009"
xmlns:mx="library:adobe/flex/halo"
xmlns:net="flash.net.*"
layout="flex.layout.BasicLayout"
creationComplete="init();">
<Script>
<![CDATA[
private const xmlObj:XML = describeType(FileReference);
private function init():void {
textArea.text = xmlObj.toXMLString();
}
private function btn_click(evt:MouseEvent):void {
fileReference.save(xmlObj, "describeType.xml");
}
]]>
</Script>
<Declarations>
<net:FileReference id="fileReference" />
</Declarations>
<mx:Panel id="panel"
width="500"
height="300"
verticalCenter="0"
horizontalCenter="0">
<mx:TextArea id="textArea"
editable="true"
width="100%"
height="100%" />
<mx:ControlBar horizontalAlign="right">
<Button id="btn"
label="Save"
click="btn_click(event);" />
</mx:ControlBar>
</mx:Panel>
</Application>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//可以使用ImageSnapshot类来抓取截图,并通过将ByteArray交给FileReference类的save()方法对象保存到本地硬盘:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://yecon.blog.hexun.com/31031093_d.html -->
<Application name="FileReference_save_test"
xmlns="http://ns.adobe.com/mxml/2009"
xmlns:mx="library:adobe/flex/halo"
xmlns:net="flash.net.*"
layout="flex.layout.BasicLayout"
creationComplete="init();">
<Script>
<![CDATA[
import mx.graphics.ImageSnapshot;
import mx.graphics.codec.*;
private const jpegEnc:JPEGEncoder = new JPEGEncoder();
private const xmlObj:XML = describeType(FileReference);
private function init():void {
textArea.text = xmlObj.toXMLString();
}
private function btn_click(evt:MouseEvent):void {
var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(panel, 0, jpegEnc);
fileReference.save(imageSnap.data, "describeType.jpg");
}
]]>
</Script>
<Declarations>
<net:FileReference id="fileReference" />
</Declarations>
<mx:Panel id="panel"
width="500"
height="300"
verticalCenter="0"
horizontalCenter="0">
<mx:TextArea id="textArea"
editable="true"
width="100%"
height="100%" />
<mx:ControlBar horizontalAlign="right">
<Button id="btn"
label="Save"
click="btn_click(event);" />
</mx:ControlBar>
</mx:Panel>
</Application>
更多精彩内容其他人还在看

Flex 对象持久化

总有人问我关于Flex对象序列化和持久化的问题,很多人认为对象不能拷贝到服务器,其实浅度的拷贝是可以做到的。
收藏 0 赞 0 分享

XML TO ArrayCollection 两种实现方式

最近研究FLEX,在网上看过100遍同一篇文章,结果测试不通,不知道到底能不能跑通,最后翻资料自己试验处理。
收藏 0 赞 0 分享

java TO ArrayCollection

因为new ArrayCollection 需要 array对象,event.result是空间返回对象(JAVA方法返回值)所以类型不同无法使用new 构造ArrayCollection ,可是恶心的FLEX偏偏支持javalist=ArrayCollection
收藏 0 赞 0 分享

Flex DataGrid DataGridColumn数据颜色多样化-类型替换

用得多了,发觉自己了解的真的是九牛之一毛都没有,最近用到了从后台读出数据时显示的问题,相信很多人都有用整形数据来代替字符串数据的情况
收藏 0 赞 0 分享

flex PopUpManager使用说明

PopUpManager在产生TitleWindow时应记录当前的TitleWindow,目前只能通过1)获取
收藏 0 赞 0 分享

Flex 字符串ReplaceAll使用说明

用过FLEX中String类型的朋友可能知道,replace这个方法并不过替换所有内容。那么我们需要替换所有内容怎么办?
收藏 0 赞 0 分享

基于Socket的网络连接 Flex与.NET互操作(一)

Flash/Flex也支持基于Socket的网络连接 ,服务器端可以是C++,VB,C#,Java等任一语言开发。监听一个网络端口便可以接收到Flash/Flex开发的客户端的连接。
收藏 0 赞 0 分享

基于WebService的数据访问(上) Flex与.NET互操作(二)

Flex提供了<mx:WebService>、<mx:HTTPService>和<mx:RemoteObject>标签来直接访问远程数据,这用于与各种不同语言环境开发提供的远程服务端数据源(如WebService)进行数据交互通信显得更加容易.
收藏 0 赞 0 分享

基于WebService的数据访问(下) Flex与.NET互操作(三)

在上一篇文章《Flex与.NET互操作(二):基于WebService的数据访问(上) 》中介绍了通过<mx:WebService>标签来访问Webservice。实际上我们也可以通过编程的方式动态的访问WebService,Flex SDK为我们提供了WebServ
收藏 0 赞 0 分享

Flex与.NET互操作 使用HttpService、URLReqeust和URLLoader加载/传输数据

在前两篇文章中分别介绍了Flex与.NET的WebService之间的数据交互通信知识,本文将介绍另外一种加载数据以及发起请求的方式。
收藏 0 赞 0 分享
查看更多