今天学习的时候,要给一个vbox填充渐变的背景颜色,效果如图所示:

 

flex 容器填充渐变的背景颜色_第1张图片 

但是查属性发现只有backgroundColor 连backgroundImage都没有  我用的是spark主题,sdk4.5.1,实现不来效果,几经后找到了解决办法:

就是在mxml文件中的VBox里面直接做一个Group,然后里面做填充颜色,就像些皮肤一样。- -代码如下

 

   
   
   
   
  1. xml version="1.0" encoding="utf-8"?> 
  2. <mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"   
  3.                     xmlns:s="library://ns.adobe.com/flex/spark"   
  4.                     xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:logic="com.runqianapp.fastreport.view.logic.*" 
  5.                     width="100%" height="100%" fontFamily="宋体" > 
  6.     <fx:Declarations> 
  7.          
  8.     fx:Declarations> 
  9.     <mx:VBox verticalGap="0" width="100%" height="100%" > 
  10.         <mx:HRule strokeWidth="1" strokeColor="#CFD9F5" width="100%"/> 
  11.         <mx:HRule strokeWidth="1" strokeColor="#DCE4F7" width="100%"/> 
  12.         <mx:HRule strokeWidth="1" strokeColor="#EBEFFB" width="100%"/> 
  13.         <mx:HRule strokeWidth="1" strokeColor="#F8F9FE" width="100%"/> 
  14.         <s:Group height="100" width="500"> 
  15.             <s:Rect width="100" height="100"> 
  16.                 <s:fill> 
  17.                     <s:LinearGradient rotation="90"> 
  18.                         <s:GradientEntry color="#F8F9FE" alpha="1.0"/> 
  19.                         <s:GradientEntry color="#CFD9F5" alpha="1.0" /> 
  20.                     s:LinearGradient> 
  21.                 s:fill> 
  22.             s:Rect> 
  23.             <s:Button label="123"/> 
  24.         s:Group>            
  25.         <mx:HRule strokeWidth="1" strokeColor="#D7E3F5" width="100%"/> 
  26.         <mx:HRule strokeWidth="1" strokeColor="#D0DBF4" width="100%"/> 
  27.         <mx:HRule strokeWidth="1" strokeColor="#C9D5F2" width="100%"/> 
  28.         <mx:HRule strokeWidth="1" strokeColor="#C5D1F2" width="100%"/> 
  29.         <mx:HRule strokeWidth="1" strokeColor="#A5B8EA" width="100%"/> 
  30.     mx:VBox>    
  31. mx:Application> 

学习ING。。~~