存取flex屏幕快照

所属分类: 网页制作 / Flash 阅读数: 1685
收藏 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>
更多精彩内容其他人还在看

AS3.0 通过类来实现一个gallery

AS3.0 通过类来实现一个gallery
收藏 0 赞 0 分享

AS3脚本编写的计时器效果代码

这篇文章通过实例代码给大家接受了AS3脚本编写的计时器效果,代码简单易懂,需要的朋友参考下吧
收藏 0 赞 0 分享

土人系列AS入门教程--基础篇

土人系列AS入门教程--基础篇
收藏 0 赞 0 分享

土人系列AS入门教程--语法篇

土人系列AS入门教程--语法篇
收藏 0 赞 0 分享

土人系列AS入门教程 -- 对象篇

土人系列AS入门教程 -- 对象篇
收藏 0 赞 0 分享

土人系列AS入门教程--实战篇

土人系列AS入门教程--实战篇
收藏 0 赞 0 分享

AS3笔记(13),sendAndLoad的继承者

AS3笔记(13),sendAndLoad的继承者
收藏 0 赞 0 分享

flashas菜鸟入门教程下载第1/2页

这个教程很老了,是闪吧的 thymecd 发布的 ,由blackhill 整理成chm 图片和 swf都是全的!! 闪吧的下载已经失效了,所以我在网上找了很久总算找了一个下载地址 下面是第三章的内容 很适合刚刚接触as的朋友
收藏 0 赞 0 分享

ActionScript 3.0 编程体验

日前,Adobe公司发布了Flash的最新版本Flash Professional 9 ActionScript 3.0 Preview,这是Flash 9的预览版,正式版本估计要到2007年才会推出,
收藏 0 赞 0 分享

As3.0 xml + Loader应用代码

简单说说AS3.0中对于XML支持的不同吧: .AS2.0对XML的支持勉勉强强,将就着可以用。而AS3.0中对XML的支持是全方位的,极其强大和灵活的
收藏 0 赞 0 分享
查看更多