The following example shows how you can set a custom bar skin for a Flex ProgressBar control by setting the barSkin style.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/27/setting-the-bar-skin-on-a-progressbar-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.events.SliderEvent;
private function init():void {
var c:Class = progressBar.getStyle("indeterminateSkin");
progressBar.setStyle("barSkin", c);
progressBar.setProgress(15, 100);
}
private function progressBar_change(evt:SliderEvent):void {
progressBar.setProgress(evt.value, 100);
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:Form styleName="plain">
<mx:FormItem label="value:">
<mx:HSlider id="slider"
minimum="0"
maximum="100"
value="15"
liveDragging="true"
snapInterval="1"
tickInterval="10"
dataTipPrecision="0"
change="progressBar_change(event);" />
</mx:FormItem>
</mx:Form>
</mx:ApplicationControlBar>
<mx:ProgressBar id="progressBar"
mode="manual"
labelPlacement="center"
height="50"
creationComplete="init();" />
</mx:Application>
View source is enabled in the following example.
You can also set the barSkin style in an external .CSS file or <mx:Style /> block, as seen in the following snippet:
ProgressBar {
barSkin: ClassReference("mx.skins.halo.ProgressIndeterminateSkin");
}
Or, you can set the barSkin style in MXML using the following snippet:
<mx:ProgressBar id="progressBar"
barSkin="mx.skins.halo.ProgressIndeterminateSkin"
mode="manual"
labelPlacement="center"
height="50" />





0 Responses to “Setting the bar skin on a ProgressBar control in Flex”
Leave a Reply