Changing the Flex ProgressBar from red -> green
Lets put a little pizazz in the Flex download ProgressBar. Really, going from, say, 0 -> 100 is great and all but maybe you need more. Like how about changing colors as it gets closer to completion?
| view source |
Now that’s more like it.
The meat and potatoes of this is in the following two methods:
private function onSlider():void {
progressBar.setProgress( slider.value, 100 );
// this will fade from 0 = green, to 100 = red
_barColor = rgbToHex( 0xFF * ( slider.value / 100 ), // this is the red part
0x00FF * ( ( 100 - slider.value ) / 100 ), // green
0 ); // no blue for you!
}
private function rgbToHex( R:uint, G:uint, B:uint ):uint {
return( R << 16 | G << 8 | B );
}







