手机
当前位置:查字典教程网 >网页设计 >Flash教程 >存取flex屏幕快照
存取flex屏幕快照
摘要:privatefunctioninit():void{textArea.text=describeType(FileReference).t...

<?xml version="1.0" encoding="utf-8"?>

<>

<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"?>

<>

<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"?>

<>

<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屏幕快照】相关文章:

flash导出FLV的尝试

Flash AS3.0实例教程:鼠标感应发光的文字旋转效果

flash声音特效实例精选--声音开关按钮

Flash AS 教程:动画事件

Flash填充变形工具的使用方法(图文教程)

Flash AS 入门教程 多维数组和双重循环使用介绍

Flash 运用图层简单实现传统数字动画效果

火柴棍人光剑短打Flash动画制作

Flash游戏开发:BitmapData的使用

flash引导线教程

精品推荐
分类导航