TextInput.as 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.xt.hb.ui
  2. {
  3. import com.xt.hb.views.TypeBase;
  4. import mx.events.FlexEvent;
  5. import com.skins.tdt.TextInputSkin;
  6. import spark.components.TextInput;
  7. public class TextInput extends spark.components.TextInput
  8. {
  9. public function TextInput()
  10. {
  11. super();
  12. addEventListener(FlexEvent.CREATION_COMPLETE,creationComplete);
  13. setStyle("skinClass",TextInputSkin);
  14. }
  15. /********
  16. * type
  17. */
  18. [Inspectable(category="General", enumeration="en,cn,int,double,email", defaultValue="cn")]
  19. public var type:String;
  20. public function creationComplete(e:FlexEvent):void{
  21. if (TypeBase.isNumberType(type))
  22. {
  23. super.setStyle("textAlign", "right");
  24. if (type == TypeBase.DOUBLE)
  25. super.restrict=TypeBase.NUM_RESTRICT;
  26. if (type == TypeBase.INT)
  27. super.restrict=TypeBase.INT_RESTRICT;
  28. }
  29. else if (type == TypeBase.EN)
  30. super.restrict=TypeBase.EN_RESTRICT;
  31. else if (type == TypeBase.EMAIL)
  32. super.restrict=TypeBase.EMAIL_RESTRICT;
  33. }
  34. }
  35. }