FLEX:可以在css文件中使用AreaStroke和AreaFill吗?

时间:2010-04-16 19:51:15

标签: flex

我想简化我的代码并将可能的内容添加到css文件中:

<mx:AreaSeries styleName="timeArea" name="A" yField="A" areaStroke="{new Stroke(0x0033CC, 2)}" areaFill="{new SolidColor(0x0033CC, 0.5)}" />

我可以将areaStroke和areaFill移动到css吗?什么是最终的CSS?

感谢

1 个答案:

答案 0 :(得分:0)

因此,虽然您无法在css中指定笔划,但您可以指定笔划的属性,即:

<mx:Metadata>
 [Style(name="areaFillColor",format="Color",type="Number)]
 [Style(name="areaStrokeColor",format="Color",type="Number)]
</mx:Metadata>
<mx:Script>
<![CDATA[
    [Bindable]
    protected var strokeColor:Number;

    [Bindable]
    protected var fillColor:Number;

    override public function styleChanged(styleProp:String):void{
         super.styleChanged(styleProp);
         //you really ought to do this in a switch statement
         strokeColor = getStyle("areaStrokeColor");
         fillColor = getStyle("areaFillColor");
    }
]]>
</mx:Script>

<mx:AreaSeries styleName="timeArea" name="A" yField="A" areaStroke="{myStroke}" areaFill="{myFill}" />

<mx:SolidColor id="myFill" color="{fillColor}" alpha=".3"/>    
<mx:Stroke id="s1" color="{strokeColor}" weight="2"/>

你的CSS看起来像(myAreaChart是父区域图表上设置的styleName):

.myAreaChart{
   areaFillColor: #f3f3f3;
   areaStrokeColor: #333333;
}