2 Replies Latest reply on Mar 28, 2011 10:11 PM by huangxinghui

    TextField problem

    huangxinghui

      use TextInput, when input too many words, the textField.scrollH will be change

       

      then set the text property, textField.scrollH will be revert to 0 ?

       

      but sometime it is not, the textField.scrollH will not change to 0, so the content can not see

       

      why?

       

      example code:

       

      MyTextInput.as

      override public function set text(value:String):void
      {
          super.text = value;
         
          if (textField)
          {
              trace("scrollH=" + textField.scrollH);
          }
      }
      

      TextInputExample.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" 
       xmlns:component="component.*"> 
          <mx:Script>
              <![CDATA[
                  private function changeHandler():void
                  {
                      textInput.text = 'aa';
                  }
              ]]>
         </mx:Script>
         <component:MyTextInput id="textInput" width="100" text="asdf"/>
         
         <mx:Button label="Change" click="changeHandler()"/>
      </mx:Application>
      

       

      Thanks a lot.

        • 1. Re: TextField problem
          Flex harUI Adobe Employee

          Set horizontalScrollPosition = 0 when setting the text.

          1 person found this helpful
          • 2. Re: TextField problem
            huangxinghui Level 1

            Thanks for you reply.

             

            set horizontalScrollPosition=0 can solve the problem.

             

            but it is strange, so i change MyTextInput like this

             

            public class MyTextInput extends TextInput
            {
                override protected function commitProperties():void
                {
                    trace("begin scrollH=" + textField.scrollH);
                    super.commitProperties();
                    trace("after scrollH=" + textField.scrollH);
                }
            }
            

            when input too many word, the textfield scrolled. Then set text="aa"

             

            the console trace:

            begin scrollH=96
            after scrollH=0
            


            seem textField set text will change the scrollH=0 by itself, but sometime it is not.

             

            the flash player version is WIN 10.0.32.18