存取flex屏幕快照
存取flex屏幕快照
发布时间:2016-12-28 来源:查字典编辑
摘要: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>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Flash教程学习
热门Flash教程学习
网页设计子分类