code:
/**
 * Coded by aimozg on 27.08.2017.
 */
package coc.xlogic {
import coc.script.Eval;

public class CaseStmt extends Statement {
	private var testExpr:Eval;
	private var valueExpr:Eval;
	private var valuesExpr:Eval;
	private var ltExpr:Eval;
	private var lteExpr:Eval;
	private var gtExpr:Eval;
	private var gteExpr:Eval;
	private var neExpr:Eval;
	public var thenBlock:StmtList = new StmtList();
	public function set testAttr(value:String):void {
		testExpr = value ? Eval.compile(value) : null;
	}
	public function set valueAttr(value:String):void {
		valueExpr = value ? Eval.compile(value) : null;
	}
	public function set valuesAttr(value:String):void {
		valuesExpr = value ? Eval.compile('[' + value + ']') : null;
	}
	public function set ltAttr(value:String):void {
		ltExpr = value ? Eval.compile(value) : null;
	}
	public function set lteAttr(value:String):void {
		lteExpr = value ? Eval.compile(value) : null;
	}
	public function set gtAttr(value:String):void {
		gtExpr = value ? Eval.compile(value) : null;
	}
	public function set gteAttr(value:String):void {
		gteExpr = value ? Eval.compile(value) : null;
	}
	public function set neAttr(value:String):void {
		neExpr = value ? Eval.compile(value) : null;
	}
	public function CaseStmt() {
	}
	public function check(context:ExecContext, useValue:Boolean, checkValue:*):Boolean {
		if (testExpr != null && testExpr.vcall(context.scopes)) {
			context.debug(this, ' => test true');
			return true;
		}
		if (useValue) {
			var pass:Boolean = true;
			if (valueExpr) pass &&= checkValue == valueExpr.vcall(context.scopes);
			if (valuesExpr) pass &&= valuesExpr.vcall(context.scopes).indexOf(checkValue) >= 0;
			if (ltExpr) pass &&= checkValue < ltExpr.vcall(context.scopes);
			if (lteExpr) pass &&= checkValue <= lteExpr.vcall(context.scopes);
			if (gtExpr) pass &&= checkValue > gtExpr.vcall(context.scopes);
			if (gteExpr) pass &&= checkValue >= gteExpr.vcall(context.scopes);
			if (neExpr) pass &&= checkValue != neExpr.vcall(context.scopes);
			context.debug(this, pass?'value pass':'value fail');
			return pass;
		}
		context.debug(this, 'skip');
		return false;
	}

	override public function execute(context:ExecContext):void {
		context.execute(thenBlock);
	}

	public function toString():String {
		return '<case' +
				(testExpr ? ' test="' + testExpr.src + '"' : '') +
				(valueExpr ? ' value="' + valueExpr.src + '"' : '') +
				(valuesExpr ? ' values="' + valuesExpr.src + '"' : '') +
				(ltExpr ? ' lt="' + ltExpr.src + '"' : '') +
				(lteExpr ? ' lte="' + lteExpr.src + '"' : '') +
				(gtExpr ? ' gt="' + gtExpr.src + '"' : '') +
				(gteExpr ? ' gte="' + gteExpr.src + '"' : '') +
				(neExpr ? ' ne="' + neExpr.src + '"' : '') +
				'> [' + thenBlock.stmts.length + '] </case>'
	}
}
}


code:
/**
 * Coded by aimozg on 27.08.2017.
 */
package coc.xlogic {
import classes.internals.Utils;

public class Compiler {
	public function Compiler() {
	}
	public function compile(x:XML):Statement {
		switch (x.nodeKind()) {
			case "element":
				return compileTag(x.localName(),x);
			case "text":
				if (Utils.trimSides(x.toString()) == '') return null;
				return compileText(x);
			default:
				return null;
		}
	}
	protected function compileTag(tag:String,x:XML):Statement {
		switch (tag) {
			case 'if':
				return compileIf(x);
			case 'switch':
				return compileSwitch(x);
			default:
				return unknownTag(tag,x);
		}
	}
	protected function compileText(x:XML):Statement{
		throw new Error("Encountered text element "+x.toString().substr(0,20));
	}
	protected function unknownTag(tag:String,x:XML):Statement {
		throw new Error("Unknown tag "+tag);
	}
	public function compileChildren(x:XML):StmtList {
		return new StmtList(compileChildrenInto(x,[]));
	}
	protected function compileChildrenInto(x:XML,stmts:/*Statement*/Array):/*Statement*/Array {
		for each(var item:XML in x.children()) {
			var e:Statement = compile(item);
			if (e is StmtList) {
				stmts.push.apply(stmts,(e as StmtList).stmts)
			} else if (e) stmts.push(e);
		}
		return stmts;
	}
	public function compileXMLList(x:XMLList):StmtList {
		return new StmtList(compileXMLListInto(x,[]));
	}
	protected function compileXMLListInto(x:XMLList,stmts:/*Statement*/Array):/*Statement*/Array {
		for each(var item:XML in x) {
			var e:Statement = compile(item);
			if (e is StmtList) {
				stmts.push.apply(stmts,(e as StmtList).stmts)
			} else if (e) stmts.push(e);
		}
		return stmts;
	}
	public function compileIf(x:XML):IfStmt {
		var item:XML;
		var attrs:* = attrMap(x);
		var iff:IfStmt = new IfStmt(attrs['test']);
		if ('then' in attrs) iff.thenBlock.push(compileText(x.@then[0]));
		if ('else' in attrs) iff.elseBlock = compileText(x.attribute('else')[0]);
		//noinspection JSMismatchedCollectionQueryUpdate
		var currentThen:/*Statement*/Array = iff.thenBlock;
		var currentIf:IfStmt = iff;
		var versionLock:int = 0;
		var hasElse:Boolean = false;
		var hasElseIf:Boolean = false;
		for each(item in x.children()) {
			switch (item.localName()) {
				case 'else':
					if (hasElse) {
						throw new Error("Duplicate <else> element");
					}
					if (item.children() > 0) {
						iff.elseBlock = compileChildren(item);
						hasElse = true;
						versionLock = 1;
					} else {
						currentIf.elseBlock = new StmtList();
						currentThen = (currentIf.elseBlock as StmtList).stmts;
						hasElse = true;
						versionLock = 1;
					}
					break;
				case 'elseif':
					if (hasElse) {
						throw new Error("<elseif> after <else>");
					}
					if (item.children() > 0) {
						if (versionLock == 2) {
							throw new Error("Inconsistent <elseif> versions (v2 after v1)")
						}
						if (hasElseIf) {
							throw new Error("Duplicate <elseif> in v1 <if>-block")
						}
						iff.elseBlock = compileIf(item);
						versionLock = 1;
						hasElseIf = true;
					} else {
						if (versionLock == 1) {
							throw new Error("Inconsistent <elseif> versions (v1 after v2)")
						}
						var newIf:IfStmt = new IfStmt(item.@test);
						currentIf.elseBlock = newIf;
						newIf.elseBlock = new StmtList();
						currentThen = newIf.thenBlock;
						currentIf = newIf;
						versionLock = 2;
					}
					break;
				default:
					var e:Statement = compile(item);
					if (e is StmtList) {
						currentThen.push.apply(currentThen,(e as StmtList).stmts)
					} else if (e) currentThen.push(e);
			}
		}
		return iff;
	}
	public function compileSwitch(x:XML):SwitchStmt {
		var sattrs:Object = attrMap(x);
		var hasval:Boolean           = 'value' in sattrs;
		var zwitch:SwitchStmt = new SwitchStmt(sattrs['value']);
		for each(var xcase:XML in x.elements()) {
			switch(xcase.localName()) {
				case 'case':
					var cattrs:Object = attrMap(xcase);
					var caze:CaseStmt = new CaseStmt();
					caze.testAttr = cattrs['test'];
					caze.valueAttr = cattrs['value'];
					caze.valuesAttr = cattrs['values'];
					caze.ltAttr = cattrs['lt'];
					caze.lteAttr = cattrs['lte'];
					caze.gtAttr = cattrs['gt'];
					caze.gteAttr = cattrs['gte'];
					caze.neAttr = cattrs['ne'];
					compileChildrenInto(xcase,caze.thenBlock.stmts);
					zwitch.cases.push(caze);
					break;
				case 'default':
					compileChildrenInto(xcase,zwitch.defaults.stmts);
					break;
			}
		}
		return zwitch;
	}
	public static function attrMap(x:XML):Object {
		var e:Object = {};
		for each (var k:XML in x.attributes()) {
			e[k.localName()] = k.toString();
		}
		return e;
	}
}
}

license: unknown


code:
/**
 * Coded by aimozg on 12.06.2018.
 */
package coc.xlogic {
public class Declaration extends Statement{
	public function Declaration() {
	}

	override public function execute(context:ExecContext):void {
		// do nothing, but also don't throw exception
	}
}
}


code:
/**
 * Coded by aimozg on 27.08.2017.
 */
package coc.xlogic {
import classes.internals.LoggerFactory;

import mx.logging.ILogger;

public class ExecContext {
	private static const LOGGER:ILogger = LoggerFactory.getLogger(ExecContext);

	public function ExecContext(_thiz:Array=null) {
		this._scopes = _thiz?_thiz:[];
	}
	private var _scopes:Array;
	public function get scopes():Array {
		return _scopes;
	}
	public function set scopes(value:Array):void {
		_scopes = value;
	}
	public function getObject(path:String):* {
		var p:/*String*/Array = path.split('.');
		var o:* = getValue(p[0]);
		for (var j:int = 1; j < p.length; j++) {
			if (!o) {
				LOGGER.error("[ERROR] getObject('"+path+"') -> "+o);
				return null;
			}
			o = o[p[j]];
		}
		if (!o) {
			LOGGER.error("[ERROR] getObject('"+path+"') -> "+o);
		}
		return o;
	}
	public function getValue(varname:String,inObj:String=""):* {
		if (inObj) {
			var obj:* = getObject(inObj);
			if (obj) return obj[varname];
			return undefined;
		}
		for each (var s:* in _scopes) if (varname in s) return s[varname];
		return undefined;
	}
	public function setValue(varname:String,value:*,inObj:String=""):void {
		if (inObj) {
			var obj:* = getObject(inObj);
			if (obj) {
				obj[varname] = value;
				return;
			}
			// TODO log error
			_scopes[0][varname] = value;
			return;
		}
		for each (var s:* in _scopes) {
			if (varname in s) {
				s[varname] = value;
				return;
			}
		}
		_scopes[0][varname] = value;
	}
	public function hasValue(varname:String):Boolean {
		for each (var s:* in _scopes) if (varname in s) return true;
		return false;
	}
	public function execute(stmt:Statement):void {
		stmt.execute(this);
	}
	public function executeAll(stmts:/*Statement*/Array):void {
		for each (var statement:Statement in stmts) {
			statement.execute(this);
		}
	}
	public function error(where:*,message:String):void {
		throw new Error("In "+where+": "+message);
	}
	public function pushScope(scope:Object):void {
		scopes.unshift(scope);
	}
	public function popScope():void {
		scopes.shift();
	}
	/**
	 * For debugging
	 */
	public function debug(where:*,s:String):void {
		trace(''+where+' '+s);
	}
}
}


code:
/**
 * Coded by aimozg on 27.08.2017.
 */
package coc.xlogic {
import coc.script.Eval;

public class IfStmt extends Statement {
	public var expr:Eval;
	public var thenBlock:/*Statement*/Array = [];
	public var elseBlock:Statement          = null;

	public function IfStmt(condition:String) {
		super();
		this.expr = Eval.compile(condition);
	}

	override public function execute(context:ExecContext):void {
		if (expr.vcall(context.scopes)) {
			context.debug(this,'then');
			context.executeAll(thenBlock);
		} else if (elseBlock != null) {
			context.debug(this,'else');
			context.execute(elseBlock);
		} else {
			context.debug(this,'skip');
		}
	}

	public function toString():String {
		return '<if test="'+expr.src+'"> [then '+thenBlock.length+'] '+
				(elseBlock?'<else/> ':'')+'</if>';
	}
}
}


code:
/**
 * Coded by aimozg on 27.08.2017.
 */
package coc.xlogic {
import classes.CoC_Settings;

public class Statement {
	public function Statement() {
	}
	public function execute(context:ExecContext):void{
		CoC_Settings.errorAMC("coc.xlogic.Statement","execute",""+this);
	}
}
}


code:
/**
 * Coded by aimozg on 27.08.2017.
 */
package coc.xlogic {
public class StmtList extends Statement{
	private var _stmts:/*Statement*/Array = [];

	public function get stmts():Array {
		return _stmts;
	}
	public function StmtList(init:/*Statement*/Array = null) {
		if (init!=null) _stmts.push.apply(_stmts,init);
	}

	override public function execute(context:ExecContext):void {
		context.executeAll(_stmts);
	}
}
}


code:
/**
 * Coded by aimozg on 27.08.2017.
 */
package coc.xlogic {
import coc.script.Eval;

public class SwitchStmt extends Statement{
	public var valueExpr:Eval;
	public var cases:/*CaseStmt*/Array = [];
	public var defaults:StmtList = new StmtList();

	public function SwitchStmt(valueAttr:String =null) {
		if (valueAttr) valueExpr = Eval.compile(valueAttr);
	}

	override public function execute(context:ExecContext):void {
		var hasValue:Boolean = valueExpr != null;
		var value:*          = hasValue ? valueExpr.vcall(context.scopes) : null;
		if (hasValue) context.debug(this,'value = '+value);
		else context.debug(this,'enter');
		for each (var block:CaseStmt in cases) {
			if (block.check(context, hasValue, value)) {
				context.execute(block);
				return;
			}
		}
		context.debug(this,'default');
		context.execute(defaults);
	}

	public function toString():String {
		return '<switch'+(valueExpr?' value="'+valueExpr.src+'">':'')+
				' [case '+cases.length+']'+
				' [default '+defaults.stmts.length+'] </switch>';
	}
}
}


code:
# minimalcomps
### Minimal ActionScript 3.0 UI Components for Flash

### License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Copyright (c) 2011 Keith Peters


code:
/**
 * BarChart.as
 * Keith Peters
 * version 0.9.10
 *
 * A chart component for graphing an array of numeric data as a bar graph.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.charts
{
	import flash.display.DisplayObjectContainer;

	public class BarChart extends Chart
	{
		protected var _spacing:Number = 2;
		protected var _barColor:uint = 0x999999;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this Label.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param data The array of numeric values to graph.
		 */
		public function BarChart(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, data:Array=null)
		{
			super(parent, xpos, ypos, data);
		}

		/**
		 * Graphs the numeric data in the chart.
		 */
		protected override function drawChart():void
		{
			var border:Number = 2;
			var totalSpace:Number = _spacing * _data.length;
			var barWidth:Number = (_width - border - totalSpace) / _data.length;
			var chartHeight:Number = _height - border;
			_chartHolder.x = 0;
			_chartHolder.y = _height;
			var xpos:Number = border;
			var max:Number = getMaxValue();
			var min:Number = getMinValue();
			var scale:Number = chartHeight / (max - min);
			for(var i:int = 0; i < _data.length; i++)
			{
				if(_data[i] != null)
				{
					_chartHolder.graphics.beginFill(_barColor);
					_chartHolder.graphics.drawRect(xpos, 0, barWidth, (_data[i] - min) * -scale);
					_chartHolder.graphics.endFill();
				}
				xpos += barWidth + _spacing;
			}
		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

		/**
		 * Sets/gets the amount of space shown between each bar. If this is too wide, bars may become invisible.
		 */
		public function set spacing(value:Number):void
		{
			_spacing = value;
			invalidate();
		}
		public function get spacing():Number
		{
			return _spacing;
		}

		/**
		 * Sets/gets the color of the bars.
		 */
		public function set barColor(value:uint):void
		{
			_barColor = value;
			invalidate();
		}
		public function get barColor():uint
		{
			return _barColor;
		}

	}
}


code:
/**
 * Chart.as
 * Keith Peters
 * version 0.9.10
 *
 * A base chart component for graphing an array of numeric data.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.charts
{

	import com.bit101.components.Component;
	import com.bit101.components.Label;
	import com.bit101.components.Panel;

	import flash.display.DisplayObjectContainer;
	import flash.display.Shape;

	public class Chart extends Component
	{
		protected var _data:Array;
		protected var _chartHolder:Shape;
		protected var _maximum:Number = 100;
		protected var _minimum:Number = 0;
		protected var _autoScale:Boolean = true;
		protected var _maxLabel:Label;
		protected var _minLabel:Label;
		protected var _showScaleLabels:Boolean = false;
		protected var _labelPrecision:int = 0;
		protected var _panel:Panel;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this Label.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param data The array of numeric values to graph.
		 */
		public function Chart(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, data:Array=null)
		{
			_data = data;
			super(parent, xpos, ypos);
		}

		/**
		 * Initializes the component.
		 */
		protected override function init() : void
		{
			super.init();
			setSize(200, 100);
		}

		/**
		 * Creates and adds the child display objects of this component.
		 */
		protected override function addChildren() : void
		{
			super.addChildren();
			_panel = new Panel(this);

			_chartHolder = new Shape();
			_panel.content.addChild(_chartHolder);

			_maxLabel = new Label();
			_minLabel = new Label();
		}

		/**
		 * Graphs the numeric data in the chart. Override in subclasses.
		 */
		protected function drawChart():void
		{
		}

		/**
		 * Gets the highest value of the numbers in the data array.
		 */
		protected function getMaxValue():Number
		{
			if(!_autoScale) return _maximum;
			var maxValue:Number = Number.NEGATIVE_INFINITY;
			for(var i:int = 0; i < _data.length; i++)
			{
				if(_data[i] != null)
				{
					maxValue = Math.max(_data[i], maxValue);
				}
			}
			return maxValue;
		}

		/**
		 * Gets the lowest value of the numbers in the data array.
		 */
		protected function getMinValue():Number
		{
			if(!_autoScale) return _minimum;
			var minValue:Number = Number.POSITIVE_INFINITY;
			for(var i:int = 0; i < _data.length; i++)
			{
				if(_data[i] != null)
				{
					minValue = Math.min(_data[i], minValue);
				}
			}
			return minValue;
		}

		///////////////////////////////////
		// public methods
		///////////////////////////////////

		/**
		 * Draws the visual ui of the component.
		 */
		public override function draw() : void
		{
			super.draw();
			_panel.setSize(width, height);
			_panel.draw();
			_chartHolder.graphics.clear();
			if(_data != null)
			{
				drawChart();

				var mult:Number = Math.pow(10, _labelPrecision);
				var maxVal:Number = Math.round(maximum * mult) / mult;
				_maxLabel.text = maxVal.toString();
				_maxLabel.draw();
				_maxLabel.x = -_maxLabel.width - 5;
				_maxLabel.y = -_maxLabel.height * 0.5;

				var minVal:Number = Math.round(minimum * mult) / mult;
				_minLabel.text = minVal.toString();
				_minLabel.draw();
				_minLabel.x = -_minLabel.width - 5;
				_minLabel.y = height - _minLabel.height * 0.5;
			}
		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

		/**
		 * Sets/gets the data array.
		 */
		public function set data(value:Array):void
		{
			_data = value;
			invalidate();
		}
		public function get data():Array
		{
			return _data;
		}

		/**
		 * Sets/gets the maximum value of the graph. Only used if autoScale is false.
		 */
		public function set maximum(value:Number):void
		{
			_maximum = value;
			invalidate();
		}
		public function get maximum():Number
		{
			if(_autoScale) return getMaxValue();
			return _maximum;
		}

		/**
		 * Sets/gets the minimum value of the graph. Only used if autoScale is false.
		 */
		public function set minimum(value:Number):void
		{
			_minimum = value;
			invalidate();
		}
		public function get minimum():Number
		{
			if(_autoScale) return getMinValue();
			return _minimum;
		}

		/**
		 * Sets/gets whether the graph will automatically set its own max and min values based on the data values.
		 */
		public function set autoScale(value:Boolean):void
		{
			_autoScale = value;
			invalidate();
		}
		public function get autoScale():Boolean
		{
			return _autoScale;
		}

		/**
		 * Sets/gets whether or not labels for max and min graph values will be shown.
		 * Note: these labels will be to the left of the x position of the chart. Chart position may need adjusting.
		 */
		public function set showScaleLabels(value:Boolean):void
		{
			_showScaleLabels = value;
			if(_showScaleLabels )
			{
				addChild(_maxLabel);
				addChild(_minLabel);
			}
			else
			{
				if(contains(_maxLabel)) removeChild(_maxLabel);
				if(contains(_minLabel)) removeChild(_minLabel);
			}
		}
		public function get showScaleLabels():Boolean
		{
			return _showScaleLabels;
		}

		/**
		 * Sets/gets the amount of decimal places shown in the scale labels.
		 */
		public function set labelPrecision(value:int):void
		{
			_labelPrecision = value;
			invalidate();
		}
		public function get labelPrecision():int
		{
			return _labelPrecision;
		}

		/**
		 * Sets / gets the size of the grid.
		 */
		public function set gridSize(value:int):void
		{
			_panel.gridSize = value;
			invalidate();
		}
		public function get gridSize():int
		{
			return _panel.gridSize;
		}

		/**
		 * Sets / gets whether or not the grid will be shown.
		 */
		public function set showGrid(value:Boolean):void
		{
			_panel.showGrid = value;
			invalidate();
		}
		public function get showGrid():Boolean
		{
			return _panel.showGrid;
		}

		/**
		 * Sets / gets the color of the grid lines.
		 */
		public function set gridColor(value:uint):void
		{
			_panel.gridColor = value;
			invalidate();
		}
		public function get gridColor():uint
		{
			return _panel.gridColor;
		}

	}
}


code:
/**
 * LineChart.as
 * Keith Peters
 * version 0.9.10
 *
 * A chart component for graphing an array of numeric data as a line graph.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.charts
{
	import flash.display.DisplayObjectContainer;

	public class LineChart extends Chart
	{
		protected var _lineWidth:Number = 1;
		protected var _lineColor:uint = 0x999999;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this Label.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param data The array of numeric values to graph.
		 */
		public function LineChart(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, data:Array=null)
		{
			super(parent, xpos, ypos, data);
		}

		/**
		 * Graphs the numeric data in the chart.
		 */
		protected override function drawChart():void
		{
			var border:Number = 2;
			var lineWidth:Number = (_width - border) / (_data.length - 1);
			var chartHeight:Number = _height - border;
			_chartHolder.x = 0;
			_chartHolder.y = _height;
			var xpos:Number = border;
			var max:Number = getMaxValue();
			var min:Number = getMinValue();
			var scale:Number = chartHeight / (max - min);
			_chartHolder.graphics.lineStyle(_lineWidth, _lineColor);
			_chartHolder.graphics.moveTo(xpos, (_data[0] - min) * -scale);
			xpos += lineWidth;
			for(var i:int = 1; i < _data.length; i++)
			{
				if(_data[i] != null)
				{
					_chartHolder.graphics.lineTo(xpos, (_data[i] - min) * -scale);
				}
				xpos += lineWidth;
			}
		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////
		/**
		 * Sets/gets the width of the line in the graph.
		 */
		public function set lineWidth(value:Number):void
		{
			_lineWidth = value;
			invalidate();
		}
		public function get lineWidth():Number
		{
			return _lineWidth;
		}

		/**
		 * Sets/gets the color of the line in the graph.
		 */
		public function set lineColor(value:uint):void
		{
			_lineColor = value;
			invalidate();
		}
		public function get lineColor():uint
		{
			return _lineColor;
		}

	}
}


code:
/**
 * PieChart.as
 * Keith Peters
 * version 0.9.10
 *
 * A chart component for graphing an array of numeric data as a pie chart.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.charts
{
	import com.bit101.components.Label;

	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;

	/**
	 * Note: the data parameter of the PieChart, like the other charts, is an array.
	 * It can be a simple array of Numbers where each number represents one slice of the pie.
	 * It can also be an array of objects.
	 * If objects are used, each object represents one slice of the pie and can contain three properties:
	 * - value: The numeric value to chart.
	 * - label: The label to display next to the slice.
	 * - color: The color to make the slice.
	 */
	public class PieChart extends Chart
	{
		protected var _sprite:Sprite;
		protected var _beginningAngle:Number = 0;
		protected var _colors:Array = [
			0xff9999, 0xffff99, 0x99ff99, 0x99ffff, 0x9999ff, 0xff99ff,
			0xffcccc, 0xffffcc, 0xccffcc, 0xccffff, 0xccccff, 0xffccff,
			0xff6666, 0xffff66, 0x99ff66, 0x66ffff, 0x6666ff, 0xff66ff,
			0xffffff
		];

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this Label.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param data The array of numeric values or objects to graph.
		 */
		public function PieChart(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, data:Array=null)
		{
			super(parent, xpos, ypos, data);
		}

		/**
		 * Initializes the component.
		 */
		protected override function init() : void
		{
			super.init();
			setSize(160, 120);
		}

		/**
		 * Creates and adds the child display objects of this component.
		 */
		protected override function addChildren():void
		{
			super.addChildren();
			_sprite = new Sprite();
			_panel.content.addChild(_sprite);
		}

		/**
		 * Graphs the numeric data in the chart.
		 */
		protected override function drawChart() : void
		{
			var radius:Number = Math.min(width - 40, height - 40) / 2;
			_sprite.x = width / 2;
			_sprite.y = height / 2;
			_sprite.graphics.clear();
			_sprite.graphics.lineStyle(0, 0x666666, 1);
			while(_sprite.numChildren > 0) _sprite.removeChildAt(0);

			var total:Number = getDataTotal();
			var startAngle:Number = _beginningAngle * Math.PI / 180;
			for(var i:int = 0; i < _data.length; i++)
			{
				var percent:Number = getValueForData(i) / total;
				var endAngle:Number = startAngle + Math.PI * 2 * percent;
				drawArc(startAngle, endAngle, radius, getColorForData(i));
				makeLabel((startAngle + endAngle) * 0.5, radius + 10, getLabelForData(i));
				startAngle = endAngle;
			}
		}

		/**
		 * Creates and positions a single label.
		 * @property angle The angle in degrees to position this label.
		 * @property radius The distance from the center to position this label.
		 * @property text The text of the label.
		 */
		protected function makeLabel(angle:Number, radius:Number, text:String):void
		{
			var label:Label = new Label(_sprite, 0, 0, text);
			label.x = Math.cos(angle) * radius;
			label.y = Math.sin(angle) * radius - label.height / 2;
			if(label.x < 0)
			{
				label.x -= label.width;
			}
		}

		/**
		 * Draws one slice of the pie.
		 * @property startAngle The beginning angle of the arc.
		 * @property endAngle The ending angle of the arc.
		 * @property radius The radius of the arc.
		 * @property color The color to draw the arc.
		 */
		protected function drawArc(startAngle:Number, endAngle:Number, radius:Number, color:uint):void
		{
			_sprite.graphics.beginFill(color);
			_sprite.graphics.moveTo(0, 0);
			for(var i:Number = startAngle; i < endAngle; i += .01)
			{
				_sprite.graphics.lineTo(Math.cos(i) * radius, Math.sin(i) * radius);
			}
			_sprite.graphics.lineTo(Math.cos(endAngle) * radius, Math.sin(endAngle) * radius);
			_sprite.graphics.lineTo(0, 0);
			_sprite.graphics.endFill();
		}

		/**
		 * Determines what label to use for the specified data.
		 * @property index The index of the data to get the label for.
		 */
		protected function getLabelForData(index:int):String
		{
			if(!(_data[index] is Number) && _data[index].label != null)
			{
				return _data[index].label;
			}
			var value:Number = Math.round(getValueForData(index) * Math.pow(10, _labelPrecision)) / Math.pow(10, _labelPrecision);
			return value.toString();
		}

		/**
		 * Determines what color to use for the specified data.
		 * @property index The index of the data to get the color for.
		 */
		protected function getColorForData(index:int):uint
		{
			if((!_data[index] is Number) && _data[index].color != null)
			{
				return _data[index].color;
			}
			if(index < _colors.length)
			{
				return _colors[index];
			}
			return Math.random() * 0xffffff;
		}

		/**
		 * Determines what value to use for the specified data.
		 * @property index The index of the data to get the value for.
		 */
		protected function getValueForData(index:int):Number
		{
			if(_data[index] is Number)
			{
				return _data[index];
			}
			if(_data[index].value != null)
			{
				return _data[index].value;
			}
			return NaN;
		}

		/**
		 * Gets the sum of all the data values.
		 */
		protected function getDataTotal():Number
		{
			var total:Number = 0;
			for(var i:int = 0; i < _data.length; i++)
			{
				total += getValueForData(i);
			}
			return total;
		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

		/**
		 * Sets/gets the default array of colors to use for each arc.
		 */
		public function set colors(value:Array):void
		{
			_colors = value;
			invalidate();
		}
		public function get colors():Array
		{
			return _colors;
		}

		/**
		 * Sets/gets the angle at which to start the first slice.
		 */
		public function set beginningAngle(value:Number):void
		{
			_beginningAngle = value;
			invalidate();
		}
		public function get beginningAngle():Number
		{
			return _beginningAngle;
		}

	}
}


code:
/**
 * Accordion.as
 * Keith Peters
 * version 0.9.10
 *
 * Essentially a VBox full of Windows. Only one Window will be expanded at any time.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;

	public class Accordion extends Component
	{
		protected var _windows:Array;
		protected var _winWidth:Number = 100;
		protected var _winHeight:Number = 100;
		protected var _vbox:VBox;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this Panel.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 */
		public function Accordion(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0)
		{
			super(parent, xpos, ypos);
		}

		/**
		 * Initializes the component.
		 */
		protected override function init():void
		{
			super.init();
			setSize(100, 120);
		}

		/**
		 * Creates and adds the child display objects of this component.
		 */
		protected override function addChildren() : void
		{
			_vbox = new VBox(this);
			_vbox.spacing = 0;

			_windows = new Array();
			for(var i:int = 0; i < 2; i++)
			{
				var window:Window = new Window(_vbox, 0, 0, "Section " + (i + 1));
				window.grips.visible = false;
				window.draggable = false;
				window.addEventListener(Event.SELECT, onWindowSelect);
				if(i != 0) window.minimized = true;
				_windows.push(window);
			}
		}

		///////////////////////////////////
		// public methods
		///////////////////////////////////

		/**
		 * Adds a new window to the bottom of the accordion.
		 * @param title The title of the new window.
		 */
		public function addWindow(title:String):void
		{
			addWindowAt(title, _windows.length);
		}

		public function addWindowAt(title:String, index:int):void
		{
			index = Math.min(index, _windows.length);
			index = Math.max(index, 0);
			var window:Window = new Window(null, 0, 0, title);
			_vbox.addChildAt(window, index);
			window.minimized = true;
			window.draggable = false;
			window.grips.visible = false;
			window.addEventListener(Event.SELECT, onWindowSelect);
			_windows.splice(index, 0, window);
			_winHeight = _height - (_windows.length - 1) * 20;
			setSize(_winWidth, _winHeight);
		}

		/**
		 * Sets the size of the component.
		 * @param w The width of the component.
		 * @param h The height of the component.
		 */
		override public function setSize(w:Number, h:Number) : void
		{
			super.setSize(w, h);
			_winWidth = w;
			_winHeight = h - (_windows.length - 1) * 20;
			draw();
		}

		override public function draw():void
		{
			_winHeight = Math.max(_winHeight, 40);
			for(var i:int = 0; i < _windows.length; i++)
			{
				_windows[i].setSize(_winWidth, _winHeight);
				_vbox.draw();
			}
		}

		/**
		 * Returns the Window at the specified index.
		 * @param index The index of the Window you want to get access to.
		 */
		public function getWindowAt(index:int):Window
		{
			return _windows[index];
		}

		///////////////////////////////////
		// event handlers
		///////////////////////////////////

		/**
		 * Called when any window is resized. If the window has been expanded, it closes all other windows.
		 */
		protected function onWindowSelect(event:Event):void
		{
			var window:Window = event.target as Window;
			if(window.minimized)
			{
				for(var i:int = 0; i < _windows.length; i++)
				{
					_windows[i].minimized = true;
				}
				window.minimized = false;
			}
			_vbox.draw();
		}

		public override function set width(w:Number):void
		{
			_winWidth = w;
			super.width = w;
		}

		public override function set height(h:Number):void
		{
			_winHeight = h - (_windows.length - 1) * 20;
			super.height = h;
		}

	}
}


code:
/**
 * Component.as
 * Keith Peters
 * version 0.9.10
 *
 * Calendar component for showing and selecting a date.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 *
 *
 * Components with text make use of the font PF Ronda Seven by Yuusuke Kamiyamane
 * This is a free font obtained from http://www.dafont.com/pf-ronda-seven.font
 */

package com.bit101.components
{
	import flash.display.DisplayObjectContainer;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.MouseEvent;

	[Event(name="select", type="flash.events.Event")]
	public class Calendar extends Panel
	{
		protected var _dateLabel:Label;
		protected var _day:int;
		protected var _dayButtons:Array = new Array();
		protected var _month:int;
		protected var _monthNames:Array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
		protected var _selection:Shape;
		protected var _year:int;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this component.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 */
		public function Calendar(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0)
		{
			super(parent, xpos, ypos);
		}

		/**
		 * Initializes the component.
		 */
		protected override function init() : void
		{
			super.init();
			setSize(140, 140);
			var today:Date = new Date();
			setDate(today);
		}

		/**
		 * Creates and adds the child display objects of this component.
		 */
		protected override function addChildren() : void
		{
			super.addChildren();
			for(var i:int = 0; i < 6; i++)
			{
				for(var j:int = 0; j < 7; j++)
				{
					var btn:PushButton = new PushButton(this.content, j * 20, 20 + i * 20);
					btn.setSize(19, 19);
					btn.addEventListener(MouseEvent.CLICK, onDayClick);
					_dayButtons.push(btn);
				}
			}

			_dateLabel = new Label(this.content, 25, 0);
			_dateLabel.autoSize = true;

			var prevYearBtn:PushButton = new PushButton(this.content, 2, 2, "«", onPrevYear);
			prevYearBtn.setSize(14, 14);

			var prevMonthBtn:PushButton = new PushButton(this.content, 17, 2, "<", onPrevMonth);
			prevMonthBtn.setSize(14, 14);

			var nextMonthBtn:PushButton = new PushButton(this.content, 108, 2, ">", onNextMonth);
			nextMonthBtn.setSize(14, 14);

			var nextYearBtn:PushButton = new PushButton(this.content, 124, 2, "»", onNextYear);
			nextYearBtn.setSize(14, 14);

			_selection = new Shape();
			_selection.graphics.beginFill(0, 0.15);
			_selection.graphics.drawRect(1, 1, 18, 18);
			this.content.addChild(_selection);
		}

		/**
		 * Gets the last day of the specfied month and year. Needed by layout.
		 * @param month The month to get the last day of.
		 * @param year The year in which the month is in (needed for leap years).
		 * @return The last day of the month.
		 */
		protected function getEndDay(month:int, year:int):int
		{
			switch(month)
			{
				case 0:		// jan
				case 2:		// mar
				case 4:		// may
				case 6:		// july
				case 7:		// aug
				case 9:		// oct
				case 11:	// dec
					return 31;
					break;

				case 1:		// feb
					if((year % 400 == 0) ||  ((year % 100 != 0) && (year % 4 == 0))) return 29;
					return 28;
					break;

				default:
					break;
			}
			// april, june, sept, nov.
			return 30;
		}

		///////////////////////////////////
		// public methods
		///////////////////////////////////

		/**
		 * Displays specified date in calendar by drawing that month and year and highlighting the day.
		 * @param date The date to display.
		 */
		public function setDate(date:Date):void
		{
			_year = date.fullYear;
			_month = date.month;
			_day = date.date;
			var startDay:int = new Date(_year, _month, 1).day;
			var endDay:int = getEndDay(_month, _year);
			for(var i:int = 0; i < 42; i++)
			{
				_dayButtons[i].visible = false;
			}
			for(i = 0; i < endDay; i++)
			{
				var btn:PushButton = _dayButtons[i + startDay];
				btn.visible = true;
				btn.label = (i + 1).toString();
				btn.tag = i + 1;
				if(i + 1 == _day)
				{
					_selection.x = btn.x;
					_selection.y = btn.y;
				}
			}

			_dateLabel.text = _monthNames[_month] + "  " + _year;
			_dateLabel.draw();
			_dateLabel.x = (width - _dateLabel.width) / 2;
		}

		/**
		 * Displays specified date in calendar by drawing that month and year and highlighting the day.
		 * @param year The year to display.
		 * @param month The month to display.
		 * @param day The day to display.
		 */
		public function setYearMonthDay(year:int, month:int, day:int):void
		{
			setDate(new Date(year, month, day));
		}

		///////////////////////////////////
		// event handlers
		///////////////////////////////////

		/**
		 * Advances the month forward by one.
		 */
		protected function onNextMonth(event:MouseEvent):void
		{
			_month++;
			if(_month > 11)
			{
				_month = 0;
				_year++;
			}
			_day = Math.min(_day,getEndDay(_month,_year));
			setYearMonthDay(_year, _month, _day);
		}

		/**
		 * Moves the month back by one.
		 */
		protected function onPrevMonth(event:MouseEvent):void
		{
			_month--;
			if(_month < 0)
			{
				_month = 11;
				_year--;
			}
			_day = Math.min(_day,getEndDay(_month,_year));
			setYearMonthDay(_year, _month, _day);
		}

		/**
		 * Advances the year forward by one.
		 */
		protected function onNextYear(event:MouseEvent):void
		{
			_year++;
			_day = Math.min(_day,getEndDay(_month,_year));
			setYearMonthDay(_year, _month, _day);
		}

		/**
		 * Moves the year back by one.
		 */
		protected function onPrevYear(event:MouseEvent):void
		{
			_year--;
			_day = Math.min(_day,getEndDay(_month,_year));
			setYearMonthDay(_year, _month, _day);
		}

		/**
		 * Called when a date button is clicked. Selects that date.
		 */
		protected function onDayClick(event:MouseEvent):void
		{
			_day = event.target.tag;
			setYearMonthDay(_year, _month, _day);
			dispatchEvent(new Event(Event.SELECT));
		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

		/**
		 * Gets the currently selected Date.
		 */
		public function get selectedDate():Date
		{
			return new Date(_year, _month, _day);
		}

		/**
		 * Gets the current month.
		 */
		public function get month():int
		{
			return _month;
		}

		/**
		 * Gets the current year.
		 */
		public function get year():int
		{
			return _year;
		}

		/**
		 * Gets the current day.
		 */
		public function get day():int
		{
			return _day;
		}
	}
}


code:
/**
 * CheckBox.as
 * Keith Peters
 * version 0.9.10
 *
 * A basic CheckBox component.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	public class CheckBox extends Component
	{
		protected var _back:Sprite;
		protected var _button:Sprite;
		protected var _label:Label;
		protected var _labelText:String = "";
		protected var _selected:Boolean = false;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this CheckBox.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param label String containing the label for this component.
		 * @param defaultHandler The event handling function to handle the default event for this component (click in this case).
		 */
		public function CheckBox(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number =  0, label:String = "", defaultHandler:Function = null)
		{
			_labelText = label;
			super(parent, xpos, ypos);
			if(defaultHandler != null)
			{
				addEventListener(MouseEvent.CLICK, defaultHandler);
			}
		}

		/**
		 * Initializes the component.
		 */
		override protected function init():void
		{
			super.init();
			buttonMode = true;
			useHandCursor = true;
			mouseChildren = false;
		}

		/**
		 * Creates the children for this component
		 */
		override protected function addChildren():void
		{
			_back = new Sprite();
			_back.filters = [getShadow(2, true)];
			addChild(_back);

			_button = new Sprite();
			_button.filters = [getShadow(1)];
			_button.visible = false;
			addChild(_button);

			_label = new Label(this, 0, 0, _labelText);
			draw();

			addEventListener(MouseEvent.CLICK, onClick);
		}

		///////////////////////////////////
		// public methods
		///////////////////////////////////

		/**
		 * Draws the visual ui of the component.
		 */
		override public function draw():void
		{
			super.draw();
			_back.graphics.clear();
			_back.graphics.beginFill(Style.BACKGROUND);
			_back.graphics.drawRect(0, 0, 10, 10);
			_back.graphics.endFill();

			_button.graphics.clear();
			_button.graphics.beginFill(Style.BUTTON_FACE);
			_button.graphics.drawRect(2, 2, 6, 6);

			_label.text = _labelText;
			_label.draw();
			_label.x = 12;
			_label.y = (10 - _label.height) / 2;
			_width = _label.width + 12;
			_height = 10;
		}

		///////////////////////////////////
		// event handler
		///////////////////////////////////

		/**
		 * Internal click handler.
		 * @param event The MouseEvent passed by the system.
		 */
		protected function onClick(event:MouseEvent):void
		{
			_selected = !_selected;
			_button.visible = _selected;
		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

		/**
		 * Sets / gets the label text shown on this CheckBox.
		 */
		public function set label(str:String):void
		{
			_labelText = str;
			invalidate();
		}
		public function get label():String
		{
			return _labelText;
		}

		/**
		 * Sets / gets the selected state of this CheckBox.
		 */
		public function set selected(s:Boolean):void
		{
			_selected = s;
			_button.visible = _selected;
		}
		public function get selected():Boolean
		{
			return _selected;
		}

		/**
		 * Sets/gets whether this component will be enabled or not.
		 */
		public override function set enabled(value:Boolean):void
		{
			super.enabled = value;
			mouseChildren = false;
		}

	}
}


code:
/**
 * ColorChooser.as
 * Keith Peters
 * version 0.9.10
 *
 * A Color Chooser component, allowing textual input, a default gradient, or custom image.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * popup color choosing code by Rashid Ghassempouri
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BlendMode;
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.GradientType;
	import flash.display.Graphics;
	import flash.display.InterpolationMethod;
	import flash.display.SpreadMethod;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Matrix;
	import flash.geom.Point;

	[Event(name="change", type="flash.events.Event")]
	public class ColorChooser extends Component
	{
		public static const TOP:String = "top";
		public static const BOTTOM:String = "bottom";

		protected var _colors:BitmapData;
		protected var _colorsContainer:Sprite;
		protected var _defaultModelColors:Array=[0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF, 0xFF0000,0xFFFFFF,0x000000];
		protected var _input:InputText;
		protected var _model:DisplayObject;
		protected var _oldColorChoice:uint = _value;
		protected var _popupAlign:String = BOTTOM;
		protected var _stage:Stage;
		protected var _swatch:Sprite;
		protected var _tmpColorChoice:uint = _value;
		protected var _usePopup:Boolean = false;
		protected var _value:uint = 0xff0000;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this ColorChooser.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param value The initial color value of this component.
		 * @param defaultHandler The event handling function to handle the default event for this component (change in this case).
		 */

		public function ColorChooser(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number =  0, value:uint = 0xff0000, defaultHandler:Function = null)
		{
			_oldColorChoice = _tmpColorChoice = _value = value;

			super(parent, xpos, ypos);

			if(defaultHandler != null)
			{
				addEventListener(Event.CHANGE, defaultHandler);
			}

		}

		/**
		 * Initializes the component.
		 */
		override protected function init():void
		{

			super.init();

			_width = 65;
			_height = 15;
			value = _value;
		}

		override protected function addChildren():void
		{
			_input = new InputText();
			_input.width = 45;
			_input.restrict = "0123456789ABCDEFabcdef";
			_input.maxChars = 6;
			addChild(_input);
			_input.addEventListener(Event.CHANGE, onChange);

			_swatch = new Sprite();
			_swatch.x = 50;
			_swatch.filters = [getShadow(2, true)];
			addChild(_swatch);

			_colorsContainer = new Sprite();
			_colorsContainer.addEventListener(Event.ADDED_TO_STAGE, onColorsAddedToStage);
			_colorsContainer.addEventListener(Event.REMOVED_FROM_STAGE, onColorsRemovedFromStage);
			_model = getDefaultModel();
			drawColors(_model);
		}

		///////////////////////////////////
		// public methods
		///////////////////////////////////

		/**
		 * Draws the visual ui of the component.
		 */
		override public function draw():void
		{
			super.draw();
			_swatch.graphics.clear();
			_swatch.graphics.beginFill(_value);
			_swatch.graphics.drawRect(0, 0, 16, 16);
			_swatch.graphics.endFill();
		}

		///////////////////////////////////
		// event handlers
		///////////////////////////////////

		/**
		 * Internal change handler.
		 * @param event The Event passed by the system.
		 */
		protected function onChange(event:Event):void
		{
			event.stopImmediatePropagation();
			_value = parseInt("0x" + _input.text, 16);
			_input.text = _input.text.toUpperCase();
			_oldColorChoice = value;
			invalidate();
			dispatchEvent(new Event(Event.CHANGE));

		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

		/**
		 * Gets / sets the color value of this ColorChooser.
		 */
		public function set value(n:uint):void
		{
			var str:String = n.toString(16).toUpperCase();
			while(str.length < 6)
			{
				str = "0" + str;
			}
			_input.text = str;
			_value = parseInt("0x" + _input.text, 16);
			invalidate();
		}
		public function get value():uint
		{
			return _value;
		}

		///////////////////////////////////
		// COLOR PICKER MODE SUPPORT
		///////////////////////////////////}

		public function get model():DisplayObject { return _model; }
		public function set model(value:DisplayObject):void
		{
			_model = value;
			if (_model!=null) {
				drawColors(_model);
				if (!usePopup) usePopup = true;
			} else {
				_model = getDefaultModel();
				drawColors(_model);
				usePopup = false;
			}
		}

		protected function drawColors(d:DisplayObject):void{
			_colors = new BitmapData(d.width, d.height);
			_colors.draw(d);
			while (_colorsContainer.numChildren) _colorsContainer.removeChildAt(0);
			_colorsContainer.addChild(new Bitmap(_colors));
			placeColors();
		}

		public function get popupAlign():String { return _popupAlign; }
		public function set popupAlign(value:String):void {
			_popupAlign = value;
			placeColors();
		}

		public function get usePopup():Boolean { return _usePopup; }
		public function set usePopup(value:Boolean):void {
			_usePopup = value;

			_swatch.buttonMode = true;
			_colorsContainer.buttonMode = true;
			_colorsContainer.addEventListener(MouseEvent.MOUSE_MOVE, browseColorChoice);
			_colorsContainer.addEventListener(MouseEvent.MOUSE_OUT, backToColorChoice);
			_colorsContainer.addEventListener(MouseEvent.CLICK, setColorChoice);
			_swatch.addEventListener(MouseEvent.CLICK, onSwatchClick);

			if (!_usePopup) {
				_swatch.buttonMode = false;
				_colorsContainer.buttonMode = false;
				_colorsContainer.removeEventListener(MouseEvent.MOUSE_MOVE, browseColorChoice);
				_colorsContainer.removeEventListener(MouseEvent.MOUSE_OUT, backToColorChoice);
				_colorsContainer.removeEventListener(MouseEvent.CLICK, setColorChoice);
				_swatch.removeEventListener(MouseEvent.CLICK, onSwatchClick);
			}
		}

		/**
		 * The color picker mode Handlers
		 */

		protected function onColorsRemovedFromStage(e:Event):void {
			_stage.removeEventListener(MouseEvent.CLICK, onStageClick);
		}

		protected function onColorsAddedToStage(e:Event):void {
			_stage = stage;
			_stage.addEventListener(MouseEvent.CLICK, onStageClick);
		}

		protected function onStageClick(e:MouseEvent):void {
			displayColors();
		}

		protected function onSwatchClick(event:MouseEvent):void
		{
			event.stopImmediatePropagation();
			displayColors();
		}

		protected function backToColorChoice(e:MouseEvent):void
		{
			value = _oldColorChoice;
		}

		protected function setColorChoice(e:MouseEvent):void {
			value = _colors.getPixel(_colorsContainer.mouseX, _colorsContainer.mouseY);
			_oldColorChoice = value;
			dispatchEvent(new Event(Event.CHANGE));
			displayColors();
		}

		protected function browseColorChoice(e:MouseEvent):void
		{
			_tmpColorChoice = _colors.getPixel(_colorsContainer.mouseX, _colorsContainer.mouseY);
			value = _tmpColorChoice;
		}

		/**
		 * The color picker mode Display functions
		 */

		protected function displayColors():void
		{
			placeColors();
			if (_colorsContainer.parent) _colorsContainer.parent.removeChild(_colorsContainer);
			else stage.addChild(_colorsContainer);
		}

		protected function placeColors():void{
			var point:Point = new Point(x, y);
			if(parent) point = parent.localToGlobal(point);
			switch (_popupAlign)
			{
				case TOP :
					_colorsContainer.x = point.x;
					_colorsContainer.y = point.y - _colorsContainer.height - 4;
				break;
				case BOTTOM :
					_colorsContainer.x = point.x;
					_colorsContainer.y = point.y + 22;
				break;
				default:
					_colorsContainer.x = point.x;
					_colorsContainer.y = point.y + 22;
				break;
			}
		}

		/**
		 * Create the default gradient Model
		 */

		protected function getDefaultModel():Sprite {
			var w:Number = 100;
			var h:Number = 100;
			var bmd:BitmapData = new BitmapData(w, h);

			var g1:Sprite = getGradientSprite(w, h, _defaultModelColors);
			bmd.draw(g1);

			var blendmodes:Array = [BlendMode.MULTIPLY,BlendMode.ADD];
			var nb:int = blendmodes.length;
			var g2:Sprite = getGradientSprite(h/nb, w, [0xFFFFFF, 0x000000]);

			for (var i:int = 0; i < nb; i++) {
				var blendmode:String = blendmodes[i];
				var m:Matrix = new Matrix();
				m.rotate(-Math.PI / 2);
				m.translate(0, h / nb * i + h/nb);
				bmd.draw(g2, m, null,blendmode);
			}

			var s:Sprite = new Sprite();
			var bm:Bitmap = new Bitmap(bmd);
			s.addChild(bm);
			return(s);
		}

		protected function getGradientSprite(w:Number, h:Number, gc:Array):Sprite
		{
			var gs:Sprite = new Sprite();
			var g:Graphics = gs.graphics;
			var gn:int = gc.length;
			var ga:Array = [];
			var gr:Array = [];
			var gm:Matrix = new Matrix(); gm.createGradientBox(w, h, 0, 0, 0);
			for (var i:int = 0; i < gn; i++) { ga.push(1); gr.push(0x00 + 0xFF / (gn - 1) * i); }
			g.beginGradientFill(GradientType.LINEAR, gc, ga, gr, gm, SpreadMethod.PAD,InterpolationMethod.RGB);
			g.drawRect(0, 0, w, h);
			g.endFill();
			return(gs);
		}
	}
}


code:
/**
 * ComboBox.as
 * Keith Peters
 * version 0.9.10
 *
 * A button that exposes a list of choices and displays the chosen item.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
	import flash.display.DisplayObjectContainer;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	[Event(name="select", type="flash.events.Event")]
	public class ComboBox extends Component
	{
		public static const TOP:String = "top";
		public static const BOTTOM:String = "bottom";

		protected var _defaultLabel:String = "";
		protected var _dropDownButton:PushButton;
		protected var _items:Array;
		protected var _labelButton:PushButton;
		protected var _list:List;
		protected var _numVisibleItems:int = 6;
		protected var _open:Boolean = false;
		protected var _openPosition:String = BOTTOM;
		protected var _stage:Stage;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this List.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param defaultLabel The label to show when no item is selected.
		 * @param items An array of items to display in the list. Either strings or objects with label property.
		 */
		public function ComboBox(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultLabel:String="", items:Array = null)
		{
			_defaultLabel = defaultLabel;
			_items = items;
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
			super(parent, xpos, ypos);
		}

		/**
		 * Initilizes the component.
		 */
		protected override function init():void
		{
			super.init();
			setSize(100, 20);
			setLabelButtonLabel();
		}

		/**
		 * Creates and adds the child display objects of this component.
		 */
		protected override function addChildren():void
		{
			super.addChildren();
			_list = new List(null, 0, 0, _items);
			_list.autoHideScrollBar = true;
			_list.addEventListener(Event.SELECT, onSelect);

			_labelButton = new PushButton(this, 0, 0, "", onDropDown);
			_dropDownButton = new PushButton(this, 0, 0, "+", onDropDown);
		}

		/**
		 * Determines what to use for the main button label and sets it.
		 */
		protected function setLabelButtonLabel():void
		{
			if(selectedItem == null)
			{
				_labelButton.label = _defaultLabel;
			}
			else if(selectedItem is String)
			{
				_labelButton.label = selectedItem as String;
			}
			else if(selectedItem.hasOwnProperty("label") && selectedItem.label is String)
			{
				_labelButton.label = selectedItem.label;
			}
			else
			{
				_labelButton.label = selectedItem.toString();
			}
		}

		/**
		 * Removes the list from the stage.
		 */
		protected function removeList():void
		{
			if(_stage.contains(_list)) _stage.removeChild(_list);
			_stage.removeEventListener(MouseEvent.CLICK, onStageClick);
			_dropDownButton.label = "+";
		}

		///////////////////////////////////
		// public methods
		///////////////////////////////////

		public override function draw():void
		{
			super.draw();
			_labelButton.setSize(_width - _height + 1, _height);
			_labelButton.draw();

			_dropDownButton.setSize(_height, _height);
			_dropDownButton.draw();
			_dropDownButton.x = _width - height;

			_list.setSize(_width, _numVisibleItems * _list.listItemHeight);
		}

		/**
		 * Adds an item to the list.
		 * @param item The item to add. Can be a string or an object containing a string property named label.
		 */
		public function addItem(item:Object):void
		{
			_list.addItem(item);
		}

		/**
		 * Adds an item to the list at the specified index.
		 * @param item The item to add. Can be a string or an object containing a string property named label.
		 * @param index The index at which to add the item.
		 */
		public function addItemAt(item:Object, index:int):void
		{
			_list.addItemAt(item, index);
		}

		/**
		 * Removes the referenced item from the list.
		 * @param item The item to remove. If a string, must match the item containing that string. If an object, must be a reference to the exact same object.
		 */
		public function removeItem(item:Object):void
		{
			_list.removeItem(item);
		}

		/**
		 * Removes the item from the list at the specified index
		 * @param index The index of the item to remove.
		 */
		public function removeItemAt(index:int):void
		{
			_list.removeItemAt(index);
		}

		/**
		 * Removes all items from the list.
		 */
		public function removeAll():void
		{
			_list.removeAll();
		}

		///////////////////////////////////
		// event handlers
		///////////////////////////////////

		/**
		 * Called when one of the top buttons is pressed. Either opens or closes the list.
		 */
		protected function onDropDown(event:MouseEvent):void
		{
			_open = !_open;
			if(_open)
			{
				var point:Point = new Point();
				if(_openPosition == BOTTOM)
				{
					point.y = _height;
				}
				else
				{
					point.y = -_numVisibleItems * _list.listItemHeight;
				}
				point = this.localToGlobal(point);
				_list.move(point.x, point.y);
				_stage.addChild(_list);
				_stage.addEventListener(MouseEvent.CLICK, onStageClick);
				_dropDownButton.label = "-";
			}
			else
			{
				removeList();
			}
		}

		/**
		 * Called when the mouse is clicked somewhere outside of the combo box when the list is open. Closes the list.
		 */
		protected function onStageClick(event:MouseEvent):void
		{
			// ignore clicks within buttons or list
			if(event.target == _dropDownButton || event.target == _labelButton) return;
			if(new Rectangle(_list.x, _list.y, _list.width, _list.height).contains(event.stageX, event.stageY)) return;

			_open = false;
			removeList();
		}

		/**
		 * Called when an item in the list is selected. Displays that item in the label button.
		 */
		protected function onSelect(event:Event):void
		{
			_open = false;
			_dropDownButton.label = "+";
			if(stage != null && stage.contains(_list))
			{
				stage.removeChild(_list);
			}
			setLabelButtonLabel();
			dispatchEvent(event);
		}

		/**
		 * Called when the component is added to the stage.
		 */
		protected function onAddedToStage(event:Event):void
		{
			_stage = stage;
		}

		/**
		 * Called when the component is removed from the stage.
		 */
		protected function onRemovedFromStage(event:Event):void
		{
			removeList();
		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

		/**
		 * Sets / gets the index of the selected list item.
		 */
		public function set selectedIndex(value:int):void
		{
			_list.selectedIndex = value;
			setLabelButtonLabel();
		}
		public function get selectedIndex():int
		{
			return _list.selectedIndex;
		}

		/**
		 * Sets / gets the item in the list, if it exists.
		 */
		public function set selectedItem(item:Object):void
		{
			_list.selectedItem = item;
			setLabelButtonLabel();
		}
		public function get selectedItem():Object
		{
			return _list.selectedItem;
		}

		/**
		 * Sets/gets the default background color of list items.
		 */
		public function set defaultColor(value:uint):void
		{
			_list.defaultColor = value;
		}
		public function get defaultColor():uint
		{
			return _list.defaultColor;
		}

		/**
		 * Sets/gets the selected background color of list items.
		 */
		public function set selectedColor(value:uint):void
		{
			_list.selectedColor = value;
		}
		public function get selectedColor():uint
		{
			return _list.selectedColor;
		}

		/**
		 * Sets/gets the rollover background color of list items.
		 */
		public function set rolloverColor(value:uint):void
		{
			_list.rolloverColor = value;
		}
		public function get rolloverColor():uint
		{
			return _list.rolloverColor;
		}

		/**
		 * Sets the height of each list item.
		 */
		public function set listItemHeight(value:Number):void
		{
			_list.listItemHeight = value;
			invalidate();
		}
		public function get listItemHeight():Number
		{
			return _list.listItemHeight;
		}

		/**
		 * Sets / gets the position the list will open on: top or bottom.
		 */
		public function set openPosition(value:String):void
		{
			_openPosition = value;
		}
		public function get openPosition():String
		{
			return _openPosition;
		}

		/**
		 * Sets / gets the label that will be shown if no item is selected.
		 */
		public function set defaultLabel(value:String):void
		{
			_defaultLabel = value;
			setLabelButtonLabel();
		}
		public function get defaultLabel():String
		{
			return _defaultLabel;
		}

		/**
		 * Sets / gets the number of visible items in the drop down list. i.e. the height of the list.
		 */
		public function set numVisibleItems(value:int):void
		{
			_numVisibleItems = Math.max(1, value);
			invalidate();
		}
		public function get numVisibleItems():int
		{
			return _numVisibleItems;
		}

		/**
		 * Sets / gets the list of items to be shown.
		 */
		public function set items(value:Array):void
		{
			_list.items = value;
		}
		public function get items():Array
		{
			return _list.items;
		}

		/**
		 * Sets / gets the class used to render list items. Must extend ListItem.
		 */
		public function set listItemClass(value:Class):void
		{
			_list.listItemClass = value;
		}
		public function get listItemClass():Class
		{
			return _list.listItemClass;
		}

		/**
		 * Sets / gets the color for alternate rows if alternateRows is set to true.
		 */
		public function set alternateColor(value:uint):void
		{
			_list.alternateColor = value;
		}
		public function get alternateColor():uint
		{
			return _list.alternateColor;
		}

		/**
		 * Sets / gets whether or not every other row will be colored with the alternate color.
		 */
		public function set alternateRows(value:Boolean):void
		{
			_list.alternateRows = value;
		}
		public function get alternateRows():Boolean
		{
			return _list.alternateRows;
		}

        /**
         * Sets / gets whether the scrollbar will auto hide when there is nothing to scroll.
         */
        public function set autoHideScrollBar(value:Boolean):void
        {
            _list.autoHideScrollBar = value;
            invalidate();
        }
        public function get autoHideScrollBar():Boolean
        {
            return _list.autoHideScrollBar;
        }

		/**
		 * Gets whether or not the combo box is currently open.
		 */
		public function get isOpen():Boolean
		{
			return _open;
		}
	}
}


code:
/**
 * Component.as
 * Keith Peters
 * version 0.9.10
 *
 * Base class for all components
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 *
 *
 * Components with text make use of the font PF Ronda Seven by Yuusuke Kamiyamane
 * This is a free font obtained from http://www.dafont.com/pf-ronda-seven.font
 */

package com.bit101.components
{
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.filters.DropShadowFilter;

	[Event(name="resize", type="flash.events.Event")]
	[Event(name="draw", type="flash.events.Event")]
	public class Component extends Sprite
	{
		[Embed(source="../../../../res/ui/pf_ronda_seven_bold.ttf", embedAsCFF="false", fontName="PF Ronda Seven", mimeType="application/x-font")]
		protected var Ronda:Class;

		protected var _width:Number = 0;
		protected var _height:Number = 0;
		protected var _tag:int = -1;
		protected var _enabled:Boolean = true;

		public static const DRAW:String = "draw";

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this component.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 */
		public function Component(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number =  0)
		{
			move(xpos, ypos);
			init();
			if(parent != null)
			{
				parent.addChild(this);
			}
		}

		/**
		 * Initilizes the component.
		 */
		protected function init():void
		{
			addChildren();
			invalidate();
		}

		/**
		 * Overriden in subclasses to create child display objects.
		 */
		protected function addChildren():void
		{

		}

		/**
		 * DropShadowFilter factory method, used in many of the components.
		 * @param dist The distance of the shadow.
		 * @param knockout Whether or not to create a knocked out shadow.
		 */
		protected function getShadow(dist:Number, knockout:Boolean = false):DropShadowFilter
		{
			return new DropShadowFilter(dist, 45, Style.DROPSHADOW, 1, dist, dist, .3, 1, knockout);
		}

		/**
		 * Marks the component to be redrawn on the next frame.
		 */
		protected function invalidate():void
		{
			addEventListener(Event.ENTER_FRAME, onInvalidate);
		}

		///////////////////////////////////
		// public methods
		///////////////////////////////////

		/**
		 * Utility method to set up usual stage align and scaling.
		 */
		public static function initStage(stage:Stage):void
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
		}

		/**
		 * Moves the component to the specified position.
		 * @param xpos the x position to move the component
		 * @param ypos the y position to move the component
		 */
		public function move(xpos:Number, ypos:Number):void
		{
			x = Math.round(xpos);
			y = Math.round(ypos);
		}

		/**
		 * Sets the size of the component.
		 * @param w The width of the component.
		 * @param h The height of the component.
		 */
		public function setSize(w:Number, h:Number):void
		{
			_width = w;
			_height = h;
			dispatchEvent(new Event(Event.RESIZE));
			invalidate();
		}

		/**
		 * Abstract draw function.
		 */
		public function draw():void
		{
			dispatchEvent(new Event(Component.DRAW));
		}

		///////////////////////////////////
		// event handlers
		///////////////////////////////////

		/**
		 * Called one frame after invalidate is called.
		 */
		protected function onInvalidate(event:Event):void
		{
			removeEventListener(Event.ENTER_FRAME, onInvalidate);
			draw();
		}

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

		/**
		 * Sets/gets the width of the component.
		 */
		override public function set width(w:Number):void
		{
			_width = w;
			invalidate();
			dispatchEvent(new Event(Event.RESIZE));
		}
		override public function get width():Number
		{
			return _width;
		}

		/**
		 * Sets/gets the height of the component.
		 */
		override public function set height(h:Number):void
		{
			_height = h;
			invalidate();
			dispatchEvent(new Event(Event.RESIZE));
		}
		override public function get height():Number
		{
			return _height;
		}

		/**
		 * Sets/gets in integer that can identify the component.
		 */
		public function set tag(value:int):void
		{
			_tag = value;
		}
		public function get tag():int
		{
			return _tag;
		}

		/**
		 * Overrides the setter for x to always place the component on a whole pixel.
		 */
		override public function set x(value:Number):void
		{
			super.x = Math.round(value);
		}

		/**
		 * Overrides the setter for y to always place the component on a whole pixel.
		 */
		override public function set y(value:Number):void
		{
			super.y = Math.round(value);
		}

		/**
		 * Sets/gets whether this component is enabled or not.
		 */
		public function set enabled(value:Boolean):void
		{
			_enabled = value;
			mouseEnabled = mouseChildren = _enabled;
            tabEnabled = value;
			alpha = _enabled ? 1.0 : 0.5;
		}
		public function get enabled():Boolean
		{
			return _enabled;
		}

	}
}


code:
/**
 * FPSMeter.as
 * Keith Peters
 * version 0.9.10
 *
 * An simple component showing the frames per second the current movie is running at.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

 package com.bit101.components
{
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	import flash.utils.getTimer;

	public class FPSMeter extends Component
	{
		protected var _label:Label;
		protected var _startTime:int;
		protected var _frames:int;
		protected var _prefix:String = "";
		protected var _fps:int = 0;

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this ColorChooser.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param prefix A string to put in front of the number value shown. Default is "FPS:".
		 */

		public function FPSMeter(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, prefix:String="FPS:")
		{
			super(parent, xpos, ypos);
			_prefix = prefix;
			_frames = 0;
			_startTime = getTimer();
			setSize(50, 20);
			if(stage != null)
			{
				addEventListener(Event.ENTER_FRAME, onEnterFrame);
			}
			addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
		}

		protected override function addChildren():void
		{
			super.addChildren();
			_label = new Label(this, 0, 0);
		}

		public override function draw():void
		{
			_label.text = _prefix + _fps.toString();
		}

		/**
		 * Internal enterFrame handler to measure fps and update label.
		 */
		protected function onEnterFrame(event:Event):void
		{
			// Increment frame count each frame. When more than a second has passed,
			// display number of accumulated frames and reset.
			// Thus FPS will only be calculated and displayed once per second.
			// There are more responsive methods that calculate FPS on every frame.
			// This method is uses less CPU and avoids the "jitter" of those other methods.
			_frames++;
			var time:int = getTimer();
			var elapsed:int = time - _startTime;
			if(elapsed >= 1000)
			{
				_fps = Math.round(_frames * 1000 / elapsed);
				_frames = 0;
				_startTime = time;
				draw();
			}
		}

		/**
		 * Stops the meter if it is removed from stage.
		 */
		protected function onRemovedFromStage(event:Event):void
		{
			stop();
		}

		/**
		 * Stops the meter by removing the enterFrame listener.
		 */
		public function stop():void
		{
			removeEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		/**
		 * Starts the meter again if it has been stopped.
		 */
		public function start():void
		{
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		/**
		 * Sets or gets the prefix shown before the number. Defaults to "FPS:".
		 */
		public function set prefix(value:String):void
		{
			_prefix = value;
		}
		public function get prefix():String
		{
			return _prefix;
		}

		/**
		 * Returns the current calculated FPS.
		 */
		public function get fps():int
		{
			return _fps;
		}
	}
}


code:
/**
 * VBox.as
 * Keith Peters
 * version 0.9.10
 *
 * A layout container for vertically aligning other components.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;

	[Event(name="resize", type="flash.events.Event")]
	public class HBox extends Component
	{
		protected var _spacing:Number = 5;
		private var _alignment:String = NONE;

		public static const TOP:String = "top";
		public static const BOTTOM:String = "bottom";
		public static const MIDDLE:String = "middle";
		public static const NONE:String = "none";

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this PushButton.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 */
		public function HBox(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number =  0)
		{
			super(parent, xpos, ypos);
		}

        /**
         * Override of addChild to force layout;
         */
        override public function addChild(child:DisplayObject) : DisplayObject
        {
            super.addChild(child);
            child.addEventListener(Event.RESIZE, onResize);
            draw();
            return child;
        }

        /**
         * Override of addChildAt to force layout;
         */
        override public function addChildAt(child:DisplayObject, index:int) : DisplayObject
        {
            super.addChildAt(child, index);
            child.addEventListener(Event.RESIZE, onResize);
            draw();
            return child;
        }

        /**
         * Override of removeChild to force layout;
         */
        override public function removeChild(child:DisplayObject):DisplayObject
        {
            super.removeChild(child);
            child.removeEventListener(Event.RESIZE, onResize);
            draw();
            return child;
        }

        /**
         * Override of removeChild to force layout;
         */
        override public function removeChildAt(index:int):DisplayObject
        {
            var child:DisplayObject = super.removeChildAt(index);
            child.removeEventListener(Event.RESIZE, onResize);
            draw();
            return child;
        }

		protected function onResize(event:Event):void
		{
			invalidate();
		}

		protected function doAlignment():void
		{
			if(_alignment != NONE)
			{
				for(var i:int = 0; i < numChildren; i++)
				{
					var child:DisplayObject = getChildAt(i);
					if(_alignment == TOP)
					{
						child.y = 0;
					}
					else if(_alignment == BOTTOM)
					{
						child.y = _height - child.height;
					}
					else if(_alignment == MIDDLE)
					{
						child.y = (_height - child.height) / 2;
					}
				}
			}
		}

		/**
		 * Draws the visual ui of the component, in this case, laying out the sub components.
		 */
		override public function draw() : void
		{
			_width = 0;
			_height = 0;
			var xpos:Number = 0;
			for(var i:int = 0; i < numChildren; i++)
			{
				var child:DisplayObject = getChildAt(i);
				child.x = xpos;
				xpos += child.width;
				xpos += _spacing;
				_width += child.width;
				_height = Math.max(_height, child.height);
			}
			doAlignment();
			_width += _spacing * (numChildren - 1);
			dispatchEvent(new Event(Event.RESIZE));
		}

		/**
		 * Gets / sets the spacing between each sub component.
		 */
		public function set spacing(s:Number):void
		{
			_spacing = s;
			invalidate();
		}
		public function get spacing():Number
		{
			return _spacing;
		}

		/**
		 * Gets / sets the vertical alignment of components in the box.
		 */
		public function set alignment(value:String):void
		{
			_alignment = value;
			invalidate();
		}
		public function get alignment():String
		{
			return _alignment;
		}
	}
}


code:
/**
 * HRangeSlider.as
 * Keith Peters
 * version 0.9.10
 *
 * A horizontal slider with two handles for selecting a range of values.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
	import flash.display.DisplayObjectContainer;

	public class HRangeSlider extends RangeSlider
	{
		public function HRangeSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null)
		{
			super(HORIZONTAL, parent, xpos, ypos, defaultHandler);
		}
	}
}


code:
/**
 * HScrollBar.as
 * Keith Peters
 * version 0.9.10
 *
 * A horizontal scroll bar for use in other components.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
	import flash.display.DisplayObjectContainer;

	/**
	 * Constructor
	 * @param parent The parent DisplayObjectContainer on which to add this ScrollBar.
	 * @param xpos The x position to place this component.
	 * @param ypos The y position to place this component.
	 * @param defaultHandler The event handling function to handle the default event for this component (change in this case).
	 */
	public class HScrollBar extends ScrollBar
	{
		public function HScrollBar(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function=null)
		{
			super(Slider.HORIZONTAL, parent, xpos, ypos, defaultHandler);
		}
	}
}


code:
/**
 * HSlider.as
 * Keith Peters
 * version 0.9.10
 *
 * A Horizontal Slider component for choosing values.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
	import flash.display.DisplayObjectContainer;

	public class HSlider extends Slider
	{
		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this HSlider.
		 * @param xpos The x position to place this component.
		 * @param ypos The y position to place this component.
		 * @param defaultHandler The event handling function to handle the default event for this component.
		 */
		public function HSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null)
		{
			super(Slider.HORIZONTAL, parent, xpos, ypos, defaultHandler);
		}

	}
}


code:
/**
 * HUISlider.as
 * Keith Peters
 * version 0.9.10
 *
 * A Horizontal slider with a label and a value label.
 *
 * Copyright (c) 2011 Keith Peters
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.bit101.components
{
    import flash.display.DisplayObjectContainer;

    public class HUISlider extends UISlider
	{

		/**
		 * Constructor
		 * @param parent The parent DisplayObjectContainer on which to add this HUISlider.
		 * @param x The x position to place this component.
		 * @param y The y position to place this component.
		 * @param label The string to use as the label for this component.
		 * @param defaultHandler The event handling function to handle the default event for this component.
		 */
		public function HUISlider(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0, label:String = "", defaultHandler:Function = null)
		{
			_sliderClass = HSlider;
			super(parent, xpos, ypos, label, defaultHandler);
		}

		/**
		 * Initializes the component.
		 */
		override protected function init():void
		{
			super.init();
			setSize(200, 18);
		}

		/**
		 * Centers the label when label text is changed.
		 */
		override protected function positionLabel():void
		{
			_valueLabel.x = _slider.x + _slider.width + 5;
		}

		///////////////////////////////////
		// public methods
		///////////////////////////////////

		/**
		 * Draws the visual ui of this component.
		 */
		override public function draw():void
		{
			super.draw();
			_slider.x = _label.width + 5;
			_slider.y = height / 2 - _slider.height / 2;
			_slider.width = width - _label.width - 50 - 10;

			_valueLabel.x = _slider.x + _slider.width + 5;
		}

		///////////////////////////////////
		// event handlers
		///////////////////////////////////

		///////////////////////////////////
		// getter/setters
		///////////////////////////////////

	}
}