package com.xt.hb.ui
{
	import com.xt.hb.views.TypeBase;
	
	import mx.events.FlexEvent;
	
	import com.skins.tdt.TextInputSkin;
	
	import spark.components.TextInput;
	
	public class TextInput extends spark.components.TextInput
	{
		public function TextInput()
		{
			super();
			addEventListener(FlexEvent.CREATION_COMPLETE,creationComplete);
			setStyle("skinClass",TextInputSkin);
		}
		
		/********
		 * type
		 */
		[Inspectable(category="General", enumeration="en,cn,int,double,email", defaultValue="cn")]
		public var type:String;
		
		public function creationComplete(e:FlexEvent):void{
			if (TypeBase.isNumberType(type))
			{
				super.setStyle("textAlign", "right");
				if (type == TypeBase.DOUBLE)
					super.restrict=TypeBase.NUM_RESTRICT;
				if (type == TypeBase.INT)
					super.restrict=TypeBase.INT_RESTRICT;
			}
			else if (type == TypeBase.EN)
				super.restrict=TypeBase.EN_RESTRICT;
			else if (type == TypeBase.EMAIL)
				super.restrict=TypeBase.EMAIL_RESTRICT;
		}
		
	}
}