home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Video-Tutorial / iPhoto / media / player.swf / scripts / mx / controls / TextInput.as < prev    next >
Encoding:
Text File  |  2011-11-11  |  29.4 KB  |  931 lines

  1. package mx.controls
  2. {
  3.    import flash.accessibility.AccessibilityProperties;
  4.    import flash.display.DisplayObject;
  5.    import flash.events.Event;
  6.    import flash.events.FocusEvent;
  7.    import flash.events.KeyboardEvent;
  8.    import flash.events.TextEvent;
  9.    import flash.system.IME;
  10.    import flash.system.IMEConversionMode;
  11.    import flash.text.TextField;
  12.    import flash.text.TextFieldAutoSize;
  13.    import flash.text.TextFieldType;
  14.    import flash.text.TextLineMetrics;
  15.    import flash.ui.Keyboard;
  16.    import mx.controls.listClasses.BaseListData;
  17.    import mx.core.EdgeMetrics;
  18.    import mx.core.IFlexDisplayObject;
  19.    import mx.core.IFlexModuleFactory;
  20.    import mx.core.IInvalidating;
  21.    import mx.core.IRectangularBorder;
  22.    import mx.core.ITextInput;
  23.    import mx.core.IUITextField;
  24.    import mx.core.UIComponent;
  25.    import mx.core.UITextField;
  26.    import mx.core.mx_internal;
  27.    import mx.events.FlexEvent;
  28.    import mx.managers.IFocusManager;
  29.    import mx.managers.IFocusManagerComponent;
  30.    import mx.styles.ISimpleStyleClient;
  31.    
  32.    use namespace mx_internal;
  33.    
  34.    public class TextInput extends UIComponent implements ITextInput
  35.    {
  36.       mx_internal static const VERSION:String = "4.5.0.20967";
  37.       
  38.       mx_internal var border:IFlexDisplayObject;
  39.       
  40.       private var textSet:Boolean;
  41.       
  42.       private var selectionChanged:Boolean = false;
  43.       
  44.       private var errorCaught:Boolean = false;
  45.       
  46.       private var _accessibilityProperties:AccessibilityProperties;
  47.       
  48.       private var accessibilityPropertiesChanged:Boolean = false;
  49.       
  50.       private var enabledChanged:Boolean = false;
  51.       
  52.       private var _tabIndex:int = -1;
  53.       
  54.       private var tabIndexChanged:Boolean = false;
  55.       
  56.       private var _condenseWhite:Boolean = false;
  57.       
  58.       private var condenseWhiteChanged:Boolean = false;
  59.       
  60.       private var _data:Object;
  61.       
  62.       private var _displayAsPassword:Boolean = false;
  63.       
  64.       private var displayAsPasswordChanged:Boolean = false;
  65.       
  66.       private var _editable:Boolean = true;
  67.       
  68.       private var editableChanged:Boolean = false;
  69.       
  70.       private var _horizontalScrollPosition:Number = 0;
  71.       
  72.       private var horizontalScrollPositionChanged:Boolean = false;
  73.       
  74.       private var _htmlText:String = "";
  75.       
  76.       private var htmlTextChanged:Boolean = false;
  77.       
  78.       private var explicitHTMLText:String = null;
  79.       
  80.       private var _imeMode:String = null;
  81.       
  82.       private var _listData:BaseListData;
  83.       
  84.       private var _maxChars:int = 0;
  85.       
  86.       private var maxCharsChanged:Boolean = false;
  87.       
  88.       private var _parentDrawsFocus:Boolean = false;
  89.       
  90.       private var _restrict:String;
  91.       
  92.       private var restrictChanged:Boolean = false;
  93.       
  94.       private var _selectable:Boolean = true;
  95.       
  96.       private var selectableChanged:Boolean = false;
  97.       
  98.       private var _selectionBeginIndex:int = 0;
  99.       
  100.       private var _selectionEndIndex:int = 0;
  101.       
  102.       private var _text:String = "";
  103.       
  104.       private var textChanged:Boolean = false;
  105.       
  106.       protected var textField:IUITextField;
  107.       
  108.       private var _textHeight:Number;
  109.       
  110.       private var _textWidth:Number;
  111.       
  112.       public function TextInput()
  113.       {
  114.          super();
  115.       }
  116.       
  117.       override public function get accessibilityProperties() : AccessibilityProperties
  118.       {
  119.          return this._accessibilityProperties;
  120.       }
  121.       
  122.       override public function set accessibilityProperties(param1:AccessibilityProperties) : void
  123.       {
  124.          if(param1 == this._accessibilityProperties)
  125.          {
  126.             return;
  127.          }
  128.          this._accessibilityProperties = param1;
  129.          this.accessibilityPropertiesChanged = true;
  130.          invalidateProperties();
  131.       }
  132.       
  133.       override public function get baselinePosition() : Number
  134.       {
  135.          if(!mx_internal::validateBaselinePosition())
  136.          {
  137.             return NaN;
  138.          }
  139.          return this.textField.y + this.textField.baselinePosition;
  140.       }
  141.       
  142.       override public function set enabled(param1:Boolean) : void
  143.       {
  144.          if(param1 == enabled)
  145.          {
  146.             return;
  147.          }
  148.          super.enabled = param1;
  149.          this.enabledChanged = true;
  150.          invalidateProperties();
  151.          if(Boolean(this.mx_internal::border) && this.mx_internal::border is IInvalidating)
  152.          {
  153.             IInvalidating(this.mx_internal::border).invalidateDisplayList();
  154.          }
  155.       }
  156.       
  157.       public function get fontContext() : IFlexModuleFactory
  158.       {
  159.          return moduleFactory;
  160.       }
  161.       
  162.       public function set fontContext(param1:IFlexModuleFactory) : void
  163.       {
  164.          this.moduleFactory = param1;
  165.       }
  166.       
  167.       override public function get tabIndex() : int
  168.       {
  169.          return this._tabIndex;
  170.       }
  171.       
  172.       override public function set tabIndex(param1:int) : void
  173.       {
  174.          if(param1 == this._tabIndex)
  175.          {
  176.             return;
  177.          }
  178.          this._tabIndex = param1;
  179.          this.tabIndexChanged = true;
  180.          invalidateProperties();
  181.       }
  182.       
  183.       [Bindable("condenseWhiteChanged")]
  184.       public function get condenseWhite() : Boolean
  185.       {
  186.          return this._condenseWhite;
  187.       }
  188.       
  189.       public function set condenseWhite(param1:Boolean) : void
  190.       {
  191.          if(param1 == this._condenseWhite)
  192.          {
  193.             return;
  194.          }
  195.          this._condenseWhite = param1;
  196.          this.condenseWhiteChanged = true;
  197.          if(this.isHTML)
  198.          {
  199.             this.htmlTextChanged = true;
  200.          }
  201.          invalidateProperties();
  202.          invalidateSize();
  203.          invalidateDisplayList();
  204.          dispatchEvent(new Event("condenseWhiteChanged"));
  205.       }
  206.       
  207.       [Bindable("dataChange")]
  208.       public function get data() : Object
  209.       {
  210.          return this._data;
  211.       }
  212.       
  213.       public function set data(param1:Object) : void
  214.       {
  215.          var _loc2_:* = undefined;
  216.          this._data = param1;
  217.          if(this._listData)
  218.          {
  219.             _loc2_ = this._listData.label;
  220.          }
  221.          else if(this._data != null)
  222.          {
  223.             if(this._data is String)
  224.             {
  225.                _loc2_ = String(this._data);
  226.             }
  227.             else
  228.             {
  229.                _loc2_ = this._data.toString();
  230.             }
  231.          }
  232.          if(_loc2_ !== undefined && !this.textSet)
  233.          {
  234.             this.text = _loc2_;
  235.             this.textSet = false;
  236.             this.textField.setSelection(0,0);
  237.          }
  238.          dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
  239.       }
  240.       
  241.       [Bindable("displayAsPasswordChanged")]
  242.       public function get displayAsPassword() : Boolean
  243.       {
  244.          return this._displayAsPassword;
  245.       }
  246.       
  247.       public function set displayAsPassword(param1:Boolean) : void
  248.       {
  249.          if(param1 == this._displayAsPassword)
  250.          {
  251.             return;
  252.          }
  253.          this._displayAsPassword = param1;
  254.          this.displayAsPasswordChanged = true;
  255.          invalidateProperties();
  256.          invalidateSize();
  257.          invalidateDisplayList();
  258.          dispatchEvent(new Event("displayAsPasswordChanged"));
  259.       }
  260.       
  261.       [Bindable("editableChanged")]
  262.       public function get editable() : Boolean
  263.       {
  264.          return this._editable;
  265.       }
  266.       
  267.       public function set editable(param1:Boolean) : void
  268.       {
  269.          if(param1 == this._editable)
  270.          {
  271.             return;
  272.          }
  273.          this._editable = param1;
  274.          this.editableChanged = true;
  275.          invalidateProperties();
  276.          dispatchEvent(new Event("editableChanged"));
  277.       }
  278.       
  279.       public function get enableIME() : Boolean
  280.       {
  281.          return this.editable;
  282.       }
  283.       
  284.       [Bindable("horizontalScrollPositionChanged")]
  285.       public function get horizontalScrollPosition() : Number
  286.       {
  287.          return this._horizontalScrollPosition;
  288.       }
  289.       
  290.       public function set horizontalScrollPosition(param1:Number) : void
  291.       {
  292.          if(param1 == this._horizontalScrollPosition)
  293.          {
  294.             return;
  295.          }
  296.          this._horizontalScrollPosition = param1;
  297.          this.horizontalScrollPositionChanged = true;
  298.          invalidateProperties();
  299.          dispatchEvent(new Event("horizontalScrollPositionChanged"));
  300.       }
  301.       
  302.       [NonCommittingChangeEvent("change")]
  303.       [Bindable("htmlTextChanged")]
  304.       public function get htmlText() : String
  305.       {
  306.          return this._htmlText;
  307.       }
  308.       
  309.       public function set htmlText(param1:String) : void
  310.       {
  311.          this.textSet = true;
  312.          if(!param1)
  313.          {
  314.             param1 = "";
  315.          }
  316.          this._htmlText = param1;
  317.          this.htmlTextChanged = true;
  318.          this._text = null;
  319.          this.explicitHTMLText = param1;
  320.          invalidateProperties();
  321.          invalidateSize();
  322.          invalidateDisplayList();
  323.          dispatchEvent(new Event("htmlTextChanged"));
  324.       }
  325.       
  326.       public function get imeMode() : String
  327.       {
  328.          return this._imeMode;
  329.       }
  330.       
  331.       public function set imeMode(param1:String) : void
  332.       {
  333.          this._imeMode = param1;
  334.       }
  335.       
  336.       private function get isHTML() : Boolean
  337.       {
  338.          return this.explicitHTMLText != null;
  339.       }
  340.       
  341.       public function get length() : int
  342.       {
  343.          return this.text != null ? this.text.length : -1;
  344.       }
  345.       
  346.       [Bindable("dataChange")]
  347.       public function get listData() : BaseListData
  348.       {
  349.          return this._listData;
  350.       }
  351.       
  352.       public function set listData(param1:BaseListData) : void
  353.       {
  354.          this._listData = param1;
  355.       }
  356.       
  357.       [Bindable("maxCharsChanged")]
  358.       public function get maxChars() : int
  359.       {
  360.          return this._maxChars;
  361.       }
  362.       
  363.       public function set maxChars(param1:int) : void
  364.       {
  365.          if(param1 == this._maxChars)
  366.          {
  367.             return;
  368.          }
  369.          this._maxChars = param1;
  370.          this.maxCharsChanged = true;
  371.          invalidateProperties();
  372.          dispatchEvent(new Event("maxCharsChanged"));
  373.       }
  374.       
  375.       public function get maxHorizontalScrollPosition() : Number
  376.       {
  377.          return !!this.textField ? this.textField.maxScrollH : 0;
  378.       }
  379.       
  380.       public function get parentDrawsFocus() : Boolean
  381.       {
  382.          return this._parentDrawsFocus;
  383.       }
  384.       
  385.       public function set parentDrawsFocus(param1:Boolean) : void
  386.       {
  387.          this._parentDrawsFocus = param1;
  388.       }
  389.       
  390.       [Bindable("restrictChanged")]
  391.       public function get restrict() : String
  392.       {
  393.          return this._restrict;
  394.       }
  395.       
  396.       public function set restrict(param1:String) : void
  397.       {
  398.          if(param1 == this._restrict)
  399.          {
  400.             return;
  401.          }
  402.          this._restrict = param1;
  403.          this.restrictChanged = true;
  404.          invalidateProperties();
  405.          dispatchEvent(new Event("restrictChanged"));
  406.       }
  407.       
  408.       public function get selectable() : Boolean
  409.       {
  410.          return this._selectable;
  411.       }
  412.       
  413.       public function set selectable(param1:Boolean) : void
  414.       {
  415.          if(this._selectable == param1)
  416.          {
  417.             return;
  418.          }
  419.          this._selectable = param1;
  420.          this.selectableChanged = true;
  421.          invalidateProperties();
  422.       }
  423.       
  424.       public function get selectionBeginIndex() : int
  425.       {
  426.          return !!this.textField ? this.textField.selectionBeginIndex : this._selectionBeginIndex;
  427.       }
  428.       
  429.       public function set selectionBeginIndex(param1:int) : void
  430.       {
  431.          this._selectionBeginIndex = param1;
  432.          this.selectionChanged = true;
  433.          invalidateProperties();
  434.       }
  435.       
  436.       public function get selectionEndIndex() : int
  437.       {
  438.          return !!this.textField ? this.textField.selectionEndIndex : this._selectionEndIndex;
  439.       }
  440.       
  441.       public function set selectionEndIndex(param1:int) : void
  442.       {
  443.          this._selectionEndIndex = param1;
  444.          this.selectionChanged = true;
  445.          invalidateProperties();
  446.       }
  447.       
  448.       [NonCommittingChangeEvent("change")]
  449.       [Bindable("textChanged")]
  450.       public function get text() : String
  451.       {
  452.          return this._text;
  453.       }
  454.       
  455.       public function set text(param1:String) : void
  456.       {
  457.          this.textSet = true;
  458.          if(!param1)
  459.          {
  460.             param1 = "";
  461.          }
  462.          if(!this.isHTML && param1 == this._text)
  463.          {
  464.             return;
  465.          }
  466.          this._text = param1;
  467.          this.textChanged = true;
  468.          this._htmlText = null;
  469.          this.explicitHTMLText = null;
  470.          invalidateProperties();
  471.          invalidateSize();
  472.          invalidateDisplayList();
  473.          dispatchEvent(new Event("textChanged"));
  474.          dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
  475.       }
  476.       
  477.       public function get textHeight() : Number
  478.       {
  479.          return this._textHeight;
  480.       }
  481.       
  482.       public function get textWidth() : Number
  483.       {
  484.          return this._textWidth;
  485.       }
  486.       
  487.       override protected function createChildren() : void
  488.       {
  489.          super.createChildren();
  490.          this.createBorder();
  491.          this.mx_internal::createTextField(-1);
  492.       }
  493.       
  494.       override protected function commitProperties() : void
  495.       {
  496.          var _loc1_:int = 0;
  497.          super.commitProperties();
  498.          if(hasFontContextChanged() && this.textField != null)
  499.          {
  500.             _loc1_ = getChildIndex(DisplayObject(this.textField));
  501.             this.mx_internal::removeTextField();
  502.             this.mx_internal::createTextField(_loc1_);
  503.             this.accessibilityPropertiesChanged = true;
  504.             this.condenseWhiteChanged = true;
  505.             this.displayAsPasswordChanged = true;
  506.             this.enabledChanged = true;
  507.             this.maxCharsChanged = true;
  508.             this.restrictChanged = true;
  509.             this.tabIndexChanged = true;
  510.             this.textChanged = true;
  511.             this.selectionChanged = true;
  512.             this.horizontalScrollPositionChanged = true;
  513.          }
  514.          if(this.accessibilityPropertiesChanged)
  515.          {
  516.             this.textField.accessibilityProperties = this._accessibilityProperties;
  517.             this.accessibilityPropertiesChanged = false;
  518.          }
  519.          if(this.condenseWhiteChanged)
  520.          {
  521.             this.textField.condenseWhite = this._condenseWhite;
  522.             this.condenseWhiteChanged = false;
  523.          }
  524.          if(this.displayAsPasswordChanged)
  525.          {
  526.             this.textField.displayAsPassword = this._displayAsPassword;
  527.             this.displayAsPasswordChanged = false;
  528.          }
  529.          if(this.enabledChanged || this.editableChanged)
  530.          {
  531.             this.textField.type = enabled && this._editable ? TextFieldType.INPUT : TextFieldType.DYNAMIC;
  532.             if(this.enabledChanged)
  533.             {
  534.                if(this.textField.enabled != enabled)
  535.                {
  536.                   this.textField.enabled = enabled;
  537.                }
  538.                this.enabledChanged = false;
  539.             }
  540.             this.selectableChanged = true;
  541.             this.editableChanged = false;
  542.          }
  543.          if(this.selectableChanged)
  544.          {
  545.             if(this._editable)
  546.             {
  547.                this.textField.selectable = enabled;
  548.             }
  549.             else
  550.             {
  551.                this.textField.selectable = enabled && this._selectable;
  552.             }
  553.             this.selectableChanged = false;
  554.          }
  555.          if(this.maxCharsChanged)
  556.          {
  557.             this.textField.maxChars = this._maxChars;
  558.             this.maxCharsChanged = false;
  559.          }
  560.          if(this.restrictChanged)
  561.          {
  562.             this.textField.restrict = this._restrict;
  563.             this.restrictChanged = false;
  564.          }
  565.          if(this.tabIndexChanged)
  566.          {
  567.             this.textField.tabIndex = this._tabIndex;
  568.             this.tabIndexChanged = false;
  569.          }
  570.          if(this.textChanged || this.htmlTextChanged)
  571.          {
  572.             if(this.isHTML)
  573.             {
  574.                this.textField.htmlText = this.explicitHTMLText;
  575.             }
  576.             else
  577.             {
  578.                this.textField.text = this._text;
  579.             }
  580.             this.textFieldChanged(false,true);
  581.             this.textChanged = false;
  582.             this.htmlTextChanged = false;
  583.          }
  584.          if(this.selectionChanged)
  585.          {
  586.             this.textField.setSelection(this._selectionBeginIndex,this._selectionEndIndex);
  587.             this.selectionChanged = false;
  588.          }
  589.          if(this.horizontalScrollPositionChanged)
  590.          {
  591.             this.textField.scrollH = this._horizontalScrollPosition;
  592.             this.horizontalScrollPositionChanged = false;
  593.          }
  594.       }
  595.       
  596.       override protected function measure() : void
  597.       {
  598.          var _loc2_:Number = NaN;
  599.          var _loc3_:Number = NaN;
  600.          var _loc4_:TextLineMetrics = null;
  601.          super.measure();
  602.          var _loc1_:EdgeMetrics = Boolean(this.mx_internal::border) && this.mx_internal::border is IRectangularBorder ? IRectangularBorder(this.mx_internal::border).borderMetrics : EdgeMetrics.EMPTY;
  603.          measuredWidth = DEFAULT_MEASURED_WIDTH;
  604.          if(this.maxChars)
  605.          {
  606.             measuredWidth = Math.min(measuredWidth,measureText("W").width * this.maxChars + _loc1_.left + _loc1_.right + 8);
  607.          }
  608.          if(!this.text || this.text == "")
  609.          {
  610.             _loc2_ = DEFAULT_MEASURED_MIN_WIDTH;
  611.             _loc3_ = measureText(" ").height + _loc1_.top + _loc1_.bottom + UITextField.mx_internal::TEXT_HEIGHT_PADDING;
  612.             _loc3_ += getStyle("paddingTop") + getStyle("paddingBottom");
  613.          }
  614.          else
  615.          {
  616.             _loc4_ = measureText(this.text);
  617.             _loc2_ = _loc4_.width + _loc1_.left + _loc1_.right + 8;
  618.             _loc3_ = _loc4_.height + _loc1_.top + _loc1_.bottom + UITextField.mx_internal::TEXT_HEIGHT_PADDING;
  619.             _loc2_ += getStyle("paddingLeft") + getStyle("paddingRight");
  620.             _loc3_ += getStyle("paddingTop") + getStyle("paddingBottom");
  621.          }
  622.          measuredWidth = Math.max(_loc2_,measuredWidth);
  623.          measuredHeight = Math.max(_loc3_,DEFAULT_MEASURED_HEIGHT);
  624.          measuredMinWidth = DEFAULT_MEASURED_MIN_WIDTH;
  625.          measuredMinHeight = DEFAULT_MEASURED_MIN_HEIGHT;
  626.       }
  627.       
  628.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  629.       {
  630.          var _loc3_:EdgeMetrics = null;
  631.          super.updateDisplayList(param1,param2);
  632.          if(this.mx_internal::border)
  633.          {
  634.             this.mx_internal::border.setActualSize(param1,param2);
  635.             _loc3_ = this.mx_internal::border is IRectangularBorder ? IRectangularBorder(this.mx_internal::border).borderMetrics : EdgeMetrics.EMPTY;
  636.          }
  637.          else
  638.          {
  639.             _loc3_ = EdgeMetrics.EMPTY;
  640.          }
  641.          var _loc4_:Number = getStyle("paddingLeft");
  642.          var _loc5_:Number = getStyle("paddingRight");
  643.          var _loc6_:Number = getStyle("paddingTop");
  644.          var _loc7_:Number = getStyle("paddingBottom");
  645.          var _loc8_:Number = _loc3_.left + _loc3_.right;
  646.          var _loc9_:Number = _loc3_.top + _loc3_.bottom + 1;
  647.          this.textField.x = _loc3_.left;
  648.          this.textField.y = _loc3_.top;
  649.          this.textField.x += _loc4_;
  650.          this.textField.y += _loc6_;
  651.          _loc8_ += _loc4_ + _loc5_;
  652.          _loc9_ += _loc6_ + _loc7_;
  653.          this.textField.width = Math.max(0,param1 - _loc8_);
  654.          this.textField.height = Math.max(0,param2 - _loc9_);
  655.       }
  656.       
  657.       override public function setFocus() : void
  658.       {
  659.          this.textField.setFocus();
  660.       }
  661.       
  662.       override protected function isOurFocus(param1:DisplayObject) : Boolean
  663.       {
  664.          return param1 == this.textField || super.isOurFocus(param1);
  665.       }
  666.       
  667.       override public function drawFocus(param1:Boolean) : void
  668.       {
  669.          if(this._parentDrawsFocus)
  670.          {
  671.             IFocusManagerComponent(parent).drawFocus(param1);
  672.             return;
  673.          }
  674.          super.drawFocus(param1);
  675.       }
  676.       
  677.       override public function styleChanged(param1:String) : void
  678.       {
  679.          var _loc2_:Boolean = param1 == null || param1 == "styleName";
  680.          super.styleChanged(param1);
  681.          if(_loc2_ || param1 == "borderSkin")
  682.          {
  683.             if(this.mx_internal::border)
  684.             {
  685.                removeChild(DisplayObject(this.mx_internal::border));
  686.                this.mx_internal::border = null;
  687.                this.createBorder();
  688.             }
  689.          }
  690.       }
  691.       
  692.       mx_internal function createTextField(param1:int) : void
  693.       {
  694.          if(!this.textField)
  695.          {
  696.             this.textField = IUITextField(createInFontContext(UITextField));
  697.             this.textField.autoSize = TextFieldAutoSize.NONE;
  698.             this.textField.enabled = enabled;
  699.             this.textField.ignorePadding = false;
  700.             this.textField.multiline = false;
  701.             this.textField.tabEnabled = true;
  702.             this.textField.wordWrap = false;
  703.             this.textField.addEventListener(Event.CHANGE,this.textField_changeHandler);
  704.             this.textField.addEventListener(TextEvent.TEXT_INPUT,this.textField_textInputHandler);
  705.             this.textField.addEventListener(Event.SCROLL,this.textField_scrollHandler);
  706.             this.textField.addEventListener("textFieldStyleChange",this.textField_textFieldStyleChangeHandler);
  707.             this.textField.addEventListener("textFormatChange",this.textField_textFormatChangeHandler);
  708.             this.textField.addEventListener("textInsert",this.textField_textModifiedHandler);
  709.             this.textField.addEventListener("textReplace",this.textField_textModifiedHandler);
  710.             this.textField.addEventListener("nativeDragDrop",this.textField_nativeDragDropHandler);
  711.             if(param1 == -1)
  712.             {
  713.                addChild(DisplayObject(this.textField));
  714.             }
  715.             else
  716.             {
  717.                addChildAt(DisplayObject(this.textField),param1);
  718.             }
  719.          }
  720.       }
  721.       
  722.       mx_internal function removeTextField() : void
  723.       {
  724.          if(this.textField)
  725.          {
  726.             this.textField.removeEventListener(Event.CHANGE,this.textField_changeHandler);
  727.             this.textField.removeEventListener(TextEvent.TEXT_INPUT,this.textField_textInputHandler);
  728.             this.textField.removeEventListener(Event.SCROLL,this.textField_scrollHandler);
  729.             this.textField.removeEventListener("textFieldStyleChange",this.textField_textFieldStyleChangeHandler);
  730.             this.textField.removeEventListener("textFormatChange",this.textField_textFormatChangeHandler);
  731.             this.textField.removeEventListener("textInsert",this.textField_textModifiedHandler);
  732.             this.textField.removeEventListener("textReplace",this.textField_textModifiedHandler);
  733.             this.textField.removeEventListener("nativeDragDrop",this.textField_nativeDragDropHandler);
  734.             removeChild(DisplayObject(this.textField));
  735.             this.textField = null;
  736.          }
  737.       }
  738.       
  739.       protected function createBorder() : void
  740.       {
  741.          var _loc1_:Class = null;
  742.          if(!this.mx_internal::border)
  743.          {
  744.             _loc1_ = getStyle("borderSkin");
  745.             if(_loc1_ != null)
  746.             {
  747.                this.mx_internal::border = new _loc1_();
  748.                if(this.mx_internal::border is ISimpleStyleClient)
  749.                {
  750.                   ISimpleStyleClient(this.mx_internal::border).styleName = this;
  751.                }
  752.                addChildAt(DisplayObject(this.mx_internal::border),0);
  753.                invalidateDisplayList();
  754.             }
  755.          }
  756.       }
  757.       
  758.       public function getLineMetrics(param1:int) : TextLineMetrics
  759.       {
  760.          return !!this.textField ? this.textField.getLineMetrics(param1) : null;
  761.       }
  762.       
  763.       public function setSelection(param1:int, param2:int) : void
  764.       {
  765.          this._selectionBeginIndex = param1;
  766.          this._selectionEndIndex = param2;
  767.          this.selectionChanged = true;
  768.          invalidateProperties();
  769.       }
  770.       
  771.       private function textFieldChanged(param1:Boolean, param2:Boolean) : void
  772.       {
  773.          var _loc3_:* = false;
  774.          var _loc4_:* = false;
  775.          if(!param1)
  776.          {
  777.             _loc3_ = this._text != this.textField.text;
  778.             this._text = this.textField.text;
  779.          }
  780.          _loc4_ = this._htmlText != this.textField.htmlText;
  781.          this._htmlText = this.textField.htmlText;
  782.          if(_loc3_)
  783.          {
  784.             dispatchEvent(new Event("textChanged"));
  785.             if(param2)
  786.             {
  787.                dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
  788.             }
  789.          }
  790.          if(_loc4_)
  791.          {
  792.             dispatchEvent(new Event("htmlTextChanged"));
  793.          }
  794.          this._textWidth = this.textField.textWidth;
  795.          this._textHeight = this.textField.textHeight;
  796.       }
  797.       
  798.       mx_internal function getTextField() : IUITextField
  799.       {
  800.          return this.textField;
  801.       }
  802.       
  803.       public function get selectionActivePosition() : int
  804.       {
  805.          return this.selectionEndIndex;
  806.       }
  807.       
  808.       public function get selectionAnchorPosition() : int
  809.       {
  810.          return this.selectionBeginIndex;
  811.       }
  812.       
  813.       public function showBorderAndBackground(param1:Boolean) : void
  814.       {
  815.          if(this.mx_internal::border)
  816.          {
  817.             this.mx_internal::border.visible = param1;
  818.          }
  819.       }
  820.       
  821.       public function selectRange(param1:int, param2:int) : void
  822.       {
  823.          this.textField.setSelection(param1,param2);
  824.       }
  825.       
  826.       override protected function focusInHandler(param1:FocusEvent) : void
  827.       {
  828.          var fm:IFocusManager;
  829.          var message:String = null;
  830.          var event:FocusEvent = param1;
  831.          if(event.target == this)
  832.          {
  833.             systemManager.stage.focus = TextField(this.textField);
  834.          }
  835.          fm = focusManager;
  836.          if(this.editable && Boolean(fm))
  837.          {
  838.             fm.showFocusIndicator = true;
  839.             if(this.textField.selectable && this._selectionBeginIndex == this._selectionEndIndex)
  840.             {
  841.                this.textField.setSelection(0,this.textField.length);
  842.             }
  843.          }
  844.          super.focusInHandler(event);
  845.          if(this._imeMode != null && this._editable)
  846.          {
  847.             try
  848.             {
  849.                if(!this.errorCaught && IME.conversionMode != IMEConversionMode.UNKNOWN)
  850.                {
  851.                   IME.conversionMode = this._imeMode;
  852.                }
  853.                this.errorCaught = false;
  854.             }
  855.             catch(e:Error)
  856.             {
  857.                errorCaught = true;
  858.                message = resourceManager.getString("controls","unsupportedMode",[_imeMode]);
  859.                throw new Error(message);
  860.             }
  861.          }
  862.       }
  863.       
  864.       override protected function focusOutHandler(param1:FocusEvent) : void
  865.       {
  866.          super.focusOutHandler(param1);
  867.          dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
  868.       }
  869.       
  870.       override protected function keyDownHandler(param1:KeyboardEvent) : void
  871.       {
  872.          switch(param1.keyCode)
  873.          {
  874.             case Keyboard.ENTER:
  875.                dispatchEvent(new FlexEvent(FlexEvent.ENTER));
  876.                if(this.textChanged || this.htmlTextChanged)
  877.                {
  878.                   validateNow();
  879.                }
  880.          }
  881.       }
  882.       
  883.       private function textField_changeHandler(param1:Event) : void
  884.       {
  885.          this.textFieldChanged(false,false);
  886.          this.textChanged = false;
  887.          this.htmlTextChanged = false;
  888.          param1.stopImmediatePropagation();
  889.          dispatchEvent(new Event(Event.CHANGE));
  890.       }
  891.       
  892.       private function textField_nativeDragDropHandler(param1:Event) : void
  893.       {
  894.          this.textField_changeHandler(param1);
  895.       }
  896.       
  897.       private function textField_textInputHandler(param1:TextEvent) : void
  898.       {
  899.          param1.stopImmediatePropagation();
  900.          var _loc2_:TextEvent = new TextEvent(TextEvent.TEXT_INPUT,false,true);
  901.          _loc2_.text = param1.text;
  902.          dispatchEvent(_loc2_);
  903.          if(_loc2_.isDefaultPrevented())
  904.          {
  905.             param1.preventDefault();
  906.          }
  907.       }
  908.       
  909.       private function textField_scrollHandler(param1:Event) : void
  910.       {
  911.          this._horizontalScrollPosition = this.textField.scrollH;
  912.       }
  913.       
  914.       private function textField_textFieldStyleChangeHandler(param1:Event) : void
  915.       {
  916.          this.textFieldChanged(true,false);
  917.       }
  918.       
  919.       private function textField_textFormatChangeHandler(param1:Event) : void
  920.       {
  921.          this.textFieldChanged(true,false);
  922.       }
  923.       
  924.       private function textField_textModifiedHandler(param1:Event) : void
  925.       {
  926.          this.textFieldChanged(false,true);
  927.       }
  928.    }
  929. }
  930.  
  931.