存取flex屏幕快照

所属分类: 网页制作 / Flash 阅读数: 1809
收藏 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 中的package(包)应用实例代码

初学者在学习AS3时会遇到什么样的问题呢?只有从初学的角度来实践,才能知道,package 这个高手们必玩的内容,对初学者来说或许就有一些困惑。
收藏 0 赞 0 分享

swfupload使用代码说明

终于在天哪joyous的帮助下,花了一天的时间,搞明白大部分内容. swfupload(以下简称su)遇到的主要问题就是,版本不同造成的极大差异, 现在的版本已经到2.1beta。我用的是2.02版,天哪用的是1.xx版。
收藏 0 赞 0 分享

Flex中最好的MVC框架Mate框架

个人感觉Mate框架非常适合开发一般运用程序,可以提高开发效率,节约成本,同时也比较好维护。但如果要做游戏或是其它控制更强的程序并不适合。
收藏 0 赞 0 分享

Flex 创建复数行文本内容的List

效果不错的flex多行文本
收藏 0 赞 0 分享

flash/flex/air的一个大问题

Close Advertisement 对HTML标签的支持得不够好。现在普遍的做法是浮一个iframe。
收藏 0 赞 0 分享

flex编程动态生成图像

程序需求:动态生成柱形图,柱形条数不确定,柱形字段不确定
收藏 0 赞 0 分享

帮助你学习 Flash / ActionScript的12个网站

Adobe Flash是一个很好的技术,该技术允许开发人员加入的互动性和平稳的动画网页。 其受欢迎程度是如此巨大,您可以看到许多网站,致力于帮助开发者有兴趣在闪光。
收藏 0 赞 0 分享

入门简单的FLEX验证码一例

入门简单的FLEX验证码一例
收藏 0 赞 0 分享

ActionScript3禁止构造请求标头Referer

ActionScript3禁止构造请求标头Referer
收藏 0 赞 0 分享

做了一个flash视频墙[附源文件与xml文件]

这篇文章主要介绍了做了一个flash视频墙[附源文件与xml文件]
收藏 0 赞 0 分享
查看更多