进度条中 barColor 属性的替代方案 +弹性4
我在 ProgressBar 组件中使用了属性“barColor”,用于显示填充颜色的性能。现在我正在将应用程序移至 Flex 4。因此,此属性在 Flex 4 中不可用。请问任何知道 barColor
属性替代方案的人都可以吗? Spark 不支持此属性。
<mx:ProgressBar xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" x="0" y="0"
height="20"
label=""
labelPlacement="center"
minimum="0"
id="iops"
maximum="1000"
mode="manual"
barSkin="{progressSkin}">
和 ProgressSkin 类:-
<fx:Metadata>
[HostComponent("progressBarComponent")]
</fx:Metadata>
<fx:Script>
<![CDATA[
override protected function initializationComplete():void {
useChromeColor = true;
super.initializationComplete();
}
]]>
</fx:Script>
<s:Rect top="0" right="0" left="0" bottom="0" id="green" includeInLayout="{hostComponent.color==0x94CF65}">
<s:fill >
<s:SolidColor color="0x94CF65" />
</s:fill>
</s:Rect>
<s:Rect top="0" right="0" left="0" bottom="0" includeInLayout="{hostComponent.color==0xFFDE53}">
<s:fill>
<s:SolidColor color="0xFFDE53" />
</s:fill>
</s:Rect>
<s:Rect top="0" right="0" left="0" bottom="0" includeInLayout="{hostComponent.color==0xFF9428}">
<s:fill>
<s:SolidColor color="0xFF9428" />
</s:fill>
</s:Rect>
我的皮肤类别有 3 种颜色。我想根据进度条值使用这种颜色。您能否帮忙解决同样的问题,如何通过在进度栏中使用相同的皮肤来显示不同的颜色。
I had used a property 'barColor' in ProgressBar component for showing performance with filling colours. Now I am moving the application to Flex 4. So this property is not available in Flex 4. Can you please any one known about the alternative for the barColor
property. Spark is not supporting this property.
<mx:ProgressBar xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" x="0" y="0"
height="20"
label=""
labelPlacement="center"
minimum="0"
id="iops"
maximum="1000"
mode="manual"
barSkin="{progressSkin}">
And ProgressSkin class:-
<fx:Metadata>
[HostComponent("progressBarComponent")]
</fx:Metadata>
<fx:Script>
<![CDATA[
override protected function initializationComplete():void {
useChromeColor = true;
super.initializationComplete();
}
]]>
</fx:Script>
<s:Rect top="0" right="0" left="0" bottom="0" id="green" includeInLayout="{hostComponent.color==0x94CF65}">
<s:fill >
<s:SolidColor color="0x94CF65" />
</s:fill>
</s:Rect>
<s:Rect top="0" right="0" left="0" bottom="0" includeInLayout="{hostComponent.color==0xFFDE53}">
<s:fill>
<s:SolidColor color="0xFFDE53" />
</s:fill>
</s:Rect>
<s:Rect top="0" right="0" left="0" bottom="0" includeInLayout="{hostComponent.color==0xFF9428}">
<s:fill>
<s:SolidColor color="0xFF9428" />
</s:fill>
</s:Rect>
I have 3 colors in the skin class. I want to use this color based on the progressBar value. Can you please help on the same, how to display the different color by using same skin in Progressbar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先我们需要编写一个进度条类并扩展进度条类
ColorChangingProgressBar.as
,然后编写进度条的皮肤类。
ColorChangingProgressBarBarSkin.mxml
并且需要将皮肤类添加到应用程序中。
ProgressBarExample.mxml
这个例子会起作用。
First we need to write a progressbar class and extend the progress bar class
ColorChangingProgressBar.as
And next Write a skin class for the progress bar.
ColorChangingProgressBarBarSkin.mxml
and need to add the skin class to the application.
ProgressBarExample.mxml
This example will work.
基于 mx.skins.spark.ProgressBarSkin 创建新的 Skin 并直接在 MXML Skin 中更改颜色并影响到组件 (barSkin="YourNewSkin")
Create a new Skin based on mx.skins.spark.ProgressBarSkin and change the color directly in the MXML Skin and affect it to the component (barSkin="YourNewSkin")
在 Spark 设计中,ProgressBar Track 默认使用镀铬颜色。 (在ProgressBarTrackSkin中定义)
所以你只需设置它:
你还可以为轨道创建自己的皮肤
因此,如果你不想从头开始,你可以复制原始皮肤并实施你的更改
原始皮肤可以在以下位置找到:
In spark design the ProgressBar Track by default uses the chrome color. (defined in ProgressBarTrackSkin)
So you just can set it:
You also can create your own skin for the track
So you can copy the original skin and implement your changes if you don't want to start from scretch
The original skin can be found at: