Flex中利用mx.graphics.ImageSnapshot的captureImage()事件获取截图的

Flex中如何利用mx.graphics.ImageSnapshot的captureImage()事件获取截图的例子

  1. <?xml version="1.0"?> 
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
  3.         layout="vertical" 
  4.         verticalAlign="middle" 
  5.         backgroundColor="white"> 
  6.   
  7.     <mx:Script> 
  8.     <![CDATA[ 
  9.         import mx.events.ItemClickEvent; 
  10.         import mx.controls.tabBarClasses.Tab; 
  11.   
  12.         private function tabBar_creationComplete():void { 
  13.             var colorArr:Array = ["red", "haloOrange", "yellow", "haloGreen", "haloBlue"]; 
  14.             var color:String; 
  15.             var tab:Tab; 
  16.             var idx:uint; 
  17.             var len:uint = tabBar.dataProvider.length; 
  18.   
  19.             for (idx = 0; idx < len; idx++) { 
  20.                 var i:int = idx % colorArr.length; 
  21.                 color = colorArr[i]; 
  22.                 tab = Tab(tabBar.getChildAt(idx)); 
  23.                 tab.setStyle("fillColors", [color, "white"]); 
  24.                 tab.setStyle("fillAlphas", [1.0, 1.0]); 
  25.                 tab.setStyle("backgroundColor", color); 
  26.             } 
  27.         } 
  28.   
  29.         private function tabBar_itemClick(evt:ItemClickEvent):void { 
  30.             viewStack.selectedIndex = evt.index; 
  31.         } 
  32.     ]]> 
  33.     </mx:Script> 
  34.   
  35.     <mx:Array id="arr"> 
  36.         <mx:Object label="Red" /> 
  37.         <mx:Object label="Orange" /> 
  38.         <mx:Object label="Yellow" /> 
  39.         <mx:Object label="Green" /> 
  40.         <mx:Object label="Blue" /> 
  41.     </mx:Array> 
  42.   
  43.     <mx:TabBar id="tabBar" 
  44.             dataProvider="{arr}" 
  45.             creationComplete="tabBar_creationComplete();" 
  46.             itemClick="tabBar_itemClick(event);" /> 
  47.   
  48.     <mx:ViewStack id="viewStack" 
  49.             width="{tabBar.width}" 
  50.             styleName="plain"> 
  51.         <mx:VBox id="redVBox" width="100%" height="100"> 
  52.             <mx:Label text="Red VBox" /> 
  53.         </mx:VBox> 
  54.         <mx:VBox id="orangeVBox" width="100%" height="100"> 
  55.             <mx:Label text="Orange VBox" /> 
  56.         </mx:VBox> 
  57.         <mx:VBox id="yellowVBox" width="100%" height="100"> 
  58.             <mx:Label text="Yellow VBox" /> 
  59.         </mx:VBox> 
  60.         <mx:VBox id="greenVBox" width="100%" height="100"> 
  61.             <mx:Label text="Green VBox" /> 
  62.         </mx:VBox> 
  63.         <mx:VBox id="blueVBox" width="100%" height="100"> 
  64.             <mx:Label text="Blue VBox" /> 
  65.         </mx:VBox> 
  66.     </mx:ViewStack> 
  67.   
  68. </mx:Application>

 

图片说明:右面为截图得到的图片

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值