I am writing a flex application that very often changes a text box. I ran into problems with a text area sometimes not displaying my changes.
The following actionscript code illustrates my problem:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
<mx:TextArea x="82" y="36" width="354" height="291" id="textArea" creationComplete="initApp()"/>
<mx:Script>
<![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;
}
]]>
</mx:Script>
</mx:Application>
When you run the above code in the flex project, it should repeatedly print, by nature, the sentence "Big brown fox jumps over a lazy dog." But, if you simultaneously enter a text field, you will see the text that the timer prints.
I'm really curious why this is happening. The single-threaded nature of bending and disabling user input for the text field when making changes should prevent this, but for some reason this does not seem to work.
, ( 100 ) , , - .
, ?