打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Flex 4中如何改变Halo TextArea背景颜色透明度的例子
userphoto

2013.01.15

关注

Flex 4中如何改变Halo TextArea背景颜色透明度的例子

来源:我要学flash网 | 作者:admin | 发表时间:2011-10-20 | 点击:835  次

接下来的例子演示了Flex 4中如何通过borderSkin样式,改变Halo TextArea背景颜色透明度。 在Flex 4中,backgroundAlpha样式不再有效,我们只能通过borderSkin样式设置自定义样式。

下面是main.mxml:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <s:Application name="TextArea_SparkSkin_backgroundAlpha_test" 
  3.         xmlns:fx="http://ns.adobe.com/mxml/2009" 
  4.         xmlns:s="library://ns.adobe.com/flash.com/article/flex' target='_blank'>flex/spark" 
  5.         xmlns:mx="library://ns.adobe.com/flash.com/article/flex' target='_blank'>flex/halo" 
  6.         backgroundColor="red"> 
  7.   
  8.     <mx:TextArea id="textArea" 
  9.             borderSkin="skins.CustomHaloTextAreaBorderSkin" 
  10.             left="50" right="50" 
  11.             top="50" bottom="50"> 
  12.         <mx:htmlText><fx:String source="lorem.html" /></mx:htmlText> 
  13.     </mx:TextArea> 
  14.   
  15. </s:Application> 

下面是skins/CustomHaloTextAreaBorderSkin.mxml的代码:

 

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <local:SparkSkinForHalo name="CustomHaloTextAreaBorderSkin" 
  3.         xmlns:fx="http://ns.adobe.com/mxml/2009" 
  4.         xmlns:s="library://ns.adobe.com/flash.com/article/flex' target='_blank'>flex/spark" 
  5.         xmlns:local="mx.skins.spark.*" 
  6.         implements="mx.core.IBorder"> 
  7.   
  8.     <fx:Script> 
  9.         <![CDATA[ 
  10.             import mx.core.EdgeMetrics; 
  11.             import mx.core.IUIComponent; 
  12.   
  13.             /* Define the skin elements that should not be colorized. */ 
  14.             static private const exclusions:Array = ["background"]; 
  15.             override public function get colorizeExclusions():Array {return exclusions;} 
  16.   
  17.             /* Define the content fill items that should be colored by the "contentBackgroundColor" style. */ 
  18.             static private const contentFill:Array = ["bgFill"]; 
  19.             override public function get contentItems():Array {return contentFill}; 
  20.   
  21.             /* Define the border items.*/ 
  22.             static private const borderItem:Array = ["borderEntry1", "borderEntry2"]; 
  23.             override protected function get borderItems():Array {return borderItem;} 
  24.   
  25.             static private const metrics:EdgeMetrics = new EdgeMetrics(2, 2, 2, 2); 
  26.   
  27.             public function get borderMetrics():EdgeMetrics { 
  28.                 return metrics; 
  29.             } 
  30.   
  31.             override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { 
  32.                 super.updateDisplayList(unscaledWidth, unscaledHeight); 
  33.   
  34.                 if (parent && (parent is IUIComponent) && !IUIComponent(parent).enabled) { 
  35.                     alpha = 0.5; 
  36.                 } else { 
  37.                     alpha = 1; 
  38.                 } 
  39.             } 
  40.         ]]> 
  41.     </fx:Script> 
  42.   
  43.     <!-- border --> 
  44.     <s:Rect left="0" right="0" top="0" bottom="0"> 
  45.         <s:stroke> 
  46.             <s:LinearGradientStroke rotation="90" weight="1"> 
  47.                 <s:GradientEntry id="borderEntry1" alpha="0.5525" /> 
  48.                 <s:GradientEntry id="borderEntry2" alpha="0.6375" /> 
  49.             </s:LinearGradientStroke> 
  50.         </s:stroke> 
  51.     </s:Rect> 
  52.   
  53.     <!-- fill --> 
  54.     <s:Rect id="background" left="1" right="1" top="1" bottom="1"> 
  55.         <s:fill> 
  56.             <s:SolidColor id="bgFill" color="0xFFFFFF" alpha="0.4" /> 
  57.         </s:fill> 
  58.     </s:Rect> 
  59.   
  60.     <!-- shadow --> 
  61.     <s:Rect left="1" top="1" right="1" height="1"> 
  62.         <s:fill> 
  63.             <s:SolidColor color="0x000000" alpha="0.12" /> 
  64.         </s:fill> 
  65.     </s:Rect> 
  66.   
  67. </local:SparkSkinForHalo> 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
碧昂斯 halo
铁芒网博 - 专注一切网页技术的个人多媒体博客
[云杜红叶Flash音乐及梅竹附加的代码注释]云水禅心古争演奏
flash动画制作实例:打造粒子烟花效果
基于Flex2的WYSIWYG编辑器设想
Python matplotlib 画雷达图
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服