package flare.widgets { import flare.display.TextSprite; import flash.display.Shape; import flash.display.Sprite; public class ProgressBar extends Sprite { private var _backColor:uint; private var _fillColor:uint; private var _barWidth:Number; private var _barHeight:Number; private var _msg:TextSprite; private var _bar:Sprite; private var _back:Shape; private var _fill:Shape; private var _progress:Number = 0; public function get progress():Number { return _progress; } public function set progress(v:Number):void { _progress = v; _fill.graphics.clear(); _fill.graphics.beginFill(_fillColor); _fill.graphics.drawRoundRect(0, 0, v*_barWidth, _barHeight, _barHeight, _barHeight); } public function get bar():Sprite { return _bar; } public function get message():TextSprite { return _msg; } public function setMessage(newMsg:String):void { _msg.text = newMsg; } public function ProgressBar(w:Number, h:Number, fillColor:uint=0xff3333, backColor:uint=0xcccccc, message:String="LOADING") { _fillColor = fillColor; _backColor = backColor; _barWidth = w; _barHeight = h; addChild(_bar = new Sprite()); addChild(_msg = new TextSprite(message)); _bar.addChild(_back = new Shape()); _bar.addChild(_fill = new Shape()); _back.graphics.beginFill(_backColor); _back.graphics.drawRoundRect(0, 0, _barWidth, _barHeight, _barHeight, _barHeight); _msg.font = "Verdana"; _msg.size = 18; _msg.color = _fillColor; _msg.letterSpacing = 2; _msg.y = 1.5 * _barHeight; } } // end of class ProgressBar }