FLEX对整个截屏或单个UI进行截图http://snowyrock.spaces.live.com/blog/cns!b8cbeb7169880b1d!447.entry 虽然FLEX 3.0已经自带了截图的类,但是FLEX 2.0本身就可以简单的做出来截图功能,而且也是很简单的,下面粘出来给大家秀一下. <?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private function captureFullScreen() : void //截屏
{
var bd : BitmapData = getBitmapData( UIComponent( mx.core.Application.application ) );
targetImage.source = new Bitmap( bd );
}
private function captureHiddenDatagrid() : void //截单个UI
{
var bd : BitmapData = getBitmapData( UIComponent( hiddenDg ) );
targetImage.source = new Bitmap( bd );
} private function getBitmapData( target : UIComponent ) : BitmapData //截图功能函数 {
var bd : BitmapData = new BitmapData( target.width, target.height );
var m : Matrix = new Matrix();
bd.draw( target, m );
return bd;
}
]]>
</mx:Script>
<mx:Button
id="captureButton"
label="Capture Full Screen"
click="captureFullScreen()" />
<mx:Button
id="captureButton2"
label="Capture Hidden Datagrid"
click="captureHiddenDatagrid()"
x="153"/>
<mx:Image
id="targetImage"
x="10"
y="30"/>
<mx:DataGrid
x="99"
y="64"
id="hiddenDg"
visible="false">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private function captureFullScreen() : void //截屏
{
var bd : BitmapData = getBitmapData( UIComponent( mx.core.Application.application ) );
targetImage.source = new Bitmap( bd );
}
private function captureHiddenDatagrid() : void //截单个UI
{
var bd : BitmapData = getBitmapData( UIComponent( hiddenDg ) );
targetImage.source = new Bitmap( bd );
} private function getBitmapData( target : UIComponent ) : BitmapData //截图功能函数 {
var bd : BitmapData = new BitmapData( target.width, target.height );
var m : Matrix = new Matrix();
bd.draw( target, m );
return bd;
}
]]>
</mx:Script>
<mx:Button
id="captureButton"
label="Capture Full Screen"
click="captureFullScreen()" />
<mx:Button
id="captureButton2"
label="Capture Hidden Datagrid"
click="captureHiddenDatagrid()"
x="153"/>
<mx:Image
id="targetImage"
x="10"
y="30"/>
<mx:DataGrid
x="99"
y="64"
id="hiddenDg"
visible="false">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="col1"/>
<mx:DataGridColumn headerText="Column 2" dataField="col2"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
http://www.auciferjay.cn/php/archives/47.html