TextAreaDecorator Fix For TextArea Component
I'm happy to report that I now have a much better solution: I wrote a class that decorates a TextArea and handles the scrollbar fix for you automatically. (It's not a complete Decorator implementation as it doesn't pass unhandled requests to the actual component but I thought that would be overkill. You're more than welcome to implement this with a trusty __resolve if you feel the need to! :))
Here's a demonstration of the bug (complete with cheesy promotional material and thumbnail portrait of yours truly) and the workaround: The TextArea to the left is a regular one and the one on the right has the decorator applied. Notice the difference in thumb heights. Page down using the track in each one to see the bug more clearly.
Using the decorator couldn't be simpler. Here's the code from the demo above:
// Import the TextAreaDecorator import com.ariaware.arp.utils.TextAreaDecorator; // Apply the Decorator to the second TextArea component var myTextAreaDecorator:TextAreaDecorator = new TextAreaDecorator ( secondTextArea ); myTextAreaDecorator.watchAndFix();
As you can see, you create an instance of the decorator, passing it a reference to your TextArea component. Then, you call the watchAndFix() method before setting the text property of your TextArea. The decorator then starts listening for changes to the htmlText property of the TextArea's label. When it hears that the property has changed, it starts looking through the TextArea's label for external media, checking to see if they have loaded. Once all external media (jpgs, swfs) have loaded, it fixes the scrollbar/thumb by asking the TextArea to redraw itself (using its invalidate() method.)
Note: You have to call this method *every time* before you set the text property as the watch is removed each time it performs a fix. (This is to prevent circular references.)
Also note: This should only be used on HTML TextAreas containing images or swfs. The bug does not appear to be present in plain text TextAreas or HTML TextAreas that do not contain images/swfs.
I hope you find this fix useful. As always, please feel free to send me your comments and suggestions regarding this, ARP or whatever else you want to get off your chest
You can download the demo (TextAreaDecorator.zip; 193kb), which contains the FLA and TextAreaDecorator class. The class will be included, among quite a few other new goodies, in the next ARP release.
The TextAreaDecorator Fix For TextArea Component article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.

Subscribe to my blog






dmaurand
I don’t suppose this wil also fix the ’selectability’ issue? I’m having a problem where sometimes the contents of a textArea (html + a jpeg) is completely selected and cannot be unselected. This is true even with myTextArea.label = “false” and/or an invisible button with no action placed above the textArea.
Anyway, it will be fun to see what this does.
May 23rd, 2005 at 12:16 amJimbo
Doesn’t work. waste of time
November 17th, 2006 at 11:29 pmAral
Hi Jimbo,
This was posted in 2004. You tested/commented in 2006 — perhaps with a different version of Flash?
July 21st, 2007 at 3:11 amsmi
Hi Aral!
I’m having the same problem with the latest release of Adobe Flex, where I load data from an XML to a TextArea. The XML consists of HTML including one (1) image. I get not scrollbars at all. Have you further investigated that issue and have a clever solution? I tried all available (findable) ones and nothing helped.
Thanks,
September 25th, 2007 at 11:12 pmMichael
Aral
Hi smi,
I haven’t tested with later versions. Sorry I can’t be of more help. If anyone does know, please feel free to leave a comment and help out!
September 26th, 2007 at 10:35 pmffed
wowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
October 14th, 2008 at 10:06 am