title: Flex textarea control not updating properly
body: <p>I am writing a flex application that involves modifying a textarea very frequently. I have encountered issues with the textarea sometimes not displaying my modifications.</p>
  
  <p>The following actionscript code illustrates my problem:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600"&gt;
      &lt;mx:TextArea x="82" y="36" width="354" height="291" id="textArea" creationComplete="initApp()"/&gt;
  
      &lt;mx:Script&gt;
          &lt;![CDATA[
              private var testSentence:String = "The big brown fox jumps over the lazy dog.";
  
              private var testCounter:int = 0;
  
              private function initApp():void {
                  var timer:Timer = new Timer(10);
                  timer.addEventListener(TimerEvent.TIMER, playSentence);
                  timer.start();
              }
  
              private function playSentence(event:TimerEvent):void {
                  textArea.editable = false;
  
                  if (testCounter == testSentence.length)  {
                      testCounter = 0;
                      textArea.text += "\n";
                  }
                  else {
                      textArea.text += testSentence.charAt(testCounter++);
                  }
  
                  textArea.editable = true;
              }
          ]]&gt;
      &lt;/mx:Script&gt;
  &lt;/mx:Application&gt;
  </code></pre>
  
  <p>When you run the above code in a flex project, it should repeatedly print, character by character, the sentence "The big brown fox jumps over the lazy dog.". But, if you are typing into the textarea at the same time, you will notice the text the timer prints is distorted.</p>
  
  <p>I am really curious as to why this happens. The single-threaded nature of flex and disabling user input for the textarea when I make modifications should prevent this from happening, but for some reason this doesn't seem to be working.</p>
  
  <p>I must note too that, when running the timer at larger intervals (around 100ms) it seems to work perfectly, so I am tempted to think it's some kind of synchronization issue in the internals of the flex framework.</p>
  
  <p>Any ideas on what could be causing the problem?</p>