存取flex屏幕快照

所属分类: 网页制作 / Flash 阅读数: 1692
收藏 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 Event总结

对于学习flex event的朋友是个不错的参考。
收藏 0 赞 0 分享

AS3打开新窗口不被屏蔽的代码

有时候flash打开的网址会出现被屏蔽的现象,如何能轻松的打开而不被屏蔽呢,下面是具体的代码。
收藏 0 赞 0 分享

Cross-domain 策略文件详解

国内这边翻译的文章挺少的,我想查一下crossdomain.xml的详细资料,只找到了这篇文章,中文文档压根没有,我不准备把整篇文章都翻译出来,感觉这个文档废话太多了,把重点内容记录一下。
收藏 0 赞 0 分享

flex 安全沙箱问题备忘

当a.com中的flash要访问b.com中的资源(如图片等)时,flex会提示安全沙箱错误!
收藏 0 赞 0 分享

flex 调试无法正常启动原因分析及解决方法

在调试Flex程序的时候,经常后遇到进度为57%无法调试的情况,本文将介绍详细的解决方法,需要的朋友可以参考下
收藏 0 赞 0 分享

使用as加载xml的示例

这篇文章主要介绍了使用as加载xml的示例,需要的朋友可以参考下
收藏 0 赞 0 分享

在flash 单击按钮,弹出指定要求的窗口

在flash 单击按钮,弹出指定要求的窗口的实现代码。
收藏 0 赞 0 分享

AS3 Flex基础知识100条

找资料的时候 看到一篇文章很实用 对新手的基本问题都可以找到,方便查找答案的时间
收藏 0 赞 0 分享

flex 绑定元数据

这篇文章算是flex初学者的的笔记吧,首先可以概览一下下文中的代码,然后我们主要是看看[Bindable]的这种用法。
收藏 0 赞 0 分享

Flex tree组件数据源、图标等修改

在flex中Tree组件的使用。使用XML作为Tree组件的数据源。
收藏 0 赞 0 分享
查看更多