3 Replies Latest reply on Jul 23, 2010 7:53 AM by gth759k

    textArea scroll to bottom

    gth759k

      Hey,

       

      I've got a text area that gets information from my server. I'm trying to figure out how to get the text area to scroll to the bottom everytime it refreshes with new data. Any suggestions?

        • 1. Re: textArea scroll to bottom
          BhaskerChari Level 4

          Hi gth759k,

           

          Try something like below:

           

          <mx:TextArea id="textArea" width="400" height="200" text="Enter Some Dummy Large Text" change="{textArea.verticalScrollPosition=textArea.maxVerticalScrollPosition}" />

           

           

          If this post answers your question or helps, please kindly mark it as such.


          Thanks,

          Bhasker Chari

          • 2. Re: textArea scroll to bottom
            gth759k Level 1

            Unfortunately, that didn't work. I don't know if it makes any difference but I have an htmlText tag inside of the textArea like this ...

             

            <mx:TextArea id="conversation" width="100%" height="100%">
                 <mx:htmlText></mx:htmlText>
            </mx:TextArea>

             

            the htmlText has to stay so do you have any other possible solutions to this. Like I said before, I just need the text area to scroll to the bottom when it reloads with new information from the server. I would just put the new information at the top, but for my app it particularly needs to be at the bottom. Any help would be appreciated. Thanks.

            • 3. Re: textArea scroll to bottom
              gth759k Level 1

              I got it working, your suggestion was right, I just put it in the update part of my app like ...

               

              <mx:Script>
                   <![CDATA[
                        private var timer:Timer;
                             
                        public function init():void {
                             var params:Object = new Object();
                             params.friend = "somebody";
                             userRequest.send(params);
                                  
                             conversation.verticalScrollPosition = conversation.maxVerticalScrollPosition;
                                  
                             timer = new Timer(1000);
                             timer.addEventListener(TimerEvent.TIMER, updateInterface);
                             timer.start();
                        }
                             
                        private function updateInterface(evt:TimerEvent):void {
                             var params:Object = new Object();
                             params.friend = mx.core.Application.application.parameters.friend;
                             userRequest.send(params);
                                  
                             conversation.verticalScrollPosition = conversation.maxVerticalScrollPosition;
                        }
                             
                        [Bindable]
                        private var connectUrl:String = "http://localhost/meesh/connect.php";
                   ]]>
              </mx:Script>
              
              <mx:HTTPService id="userRequest" url="{connectUrl}" useProxy="false" method="POST" resultFormat="text" result="conversation.htmlText = event.result.toString();"/>
                   
              <mx:Panel id="controlpanel" title="" width="100%" height="100%">
                   <mx:TextArea id="conversation" width="100%" height="100%">
                        <mx:htmlText></mx:htmlText> 
                   </mx:TextArea>
              </mx:Panel>