2 Replies Latest reply on Mar 7, 2013 7:18 AM by DeanLoganBH

    Flex 4.6 - Spark TextArea won't scroll programatically

    DotNETDev

      I'm trying to make the Spark TextArea component automatically scroll down as text is added to it.

       

      When the TextArea is first populated, the vertical scrollbar is at the bottom, and everything's cool. But if I append more text, it just outright refuses to scroll, and after spending a day fooling around with it, now it just jumps up to the top.

       

      I've tried doing the following, according to the example found here: http://devgirl.org/2010/12/16/automatically-scroll-flex-mobile-textarea/

       

      StyleableTextField(TextArea1.textDisplay).htmlText += textHTML;

      StyleableTextField(TextArea1.textDisplay).scrollV++;

       

       

      I've also tried the following two lines of code:

       

      StyleableTextField(TextArea1.textDisplay).verticalScrollPosition = int.MAX_VALUE - 1;

      TextArea1.scrollToRange(int.MAX_VALUE, int.MAX_VALUE);

       

      NOTHING WORKS! Whenever the TextArea is updated, it just scrolls back up to the top, or doesn't move at all.

       

      I had it working on iOS, but on Android, nothing would happen. And now, in the process of mucking around with it, now it just jumps up to the top of the TextArea on both platforms. I'm mostly a .NET guy, but my company is developing a mobile version of one of our products in Flex, and I'm the guy that volunteered to learn Flex, mostly by the seat of my pants.

       

      I've got it all mostly covered, just this scrolling issue is a pain in the rear. I also tried displaying the HTML content in a StageWebView, but I found out later after a bit of Googling that you can't programmatically change the vertical scroll position of a StageWebView.

       

      The weird part is, some of these properties (i.e. htmlText, scrollV, etc) are returning null in the debugger even after I've set them, which is kind of confusing. If anyone knows a better way of displaying HTML/rich text in a MOBILE environment (i.e. no TLF, I believe it's called?), then I am all ears.

       

      Can someone please help me out with this? I am absolutely stumped.

       

      By the way, here's the code for the TextArea as well:

       

      <s:TextArea id="TextArea1" width="95%" height="75%" editable="false" fontSize="{fontSize}" verticalScrollPolicy="on" selectable="false"

                                               skinClass="spark.skins.mobile.TextAreaSkin"

                                               />