Flex textarea not updating properly

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 ) , , - .

, ?

+3
2

, . , , /, stackoverflow.... ...

4 - textArea! , , :

sdk- :

, TextArea ( , ):

private var _tackOnText : String = "";
private var _tackOnTextChanged : Boolean = false;
public function set tackOnText(value:String):void
{
    _tackOnText = value;
    _tackOnTextChanged = true;
    invalidateProperties();
}

public function get tackOnText():String
{
    return _tackOnText;
}


override protected function commitProperties():void
{
    super.commitProperties();

    if(_tackOnTextChanged) {
        this.textField.text += _tackOnText;
        _tackOnText = "";
        _tackOnTextChanged = false;
    }

}

, :

if (testCounter == testSentence.length)  {
    testCounter = 0;
    textArea.tackOnText += "\n";
}
else {
    textArea.tackOnText += testSentence.charAt(testCounter++);
}

, frameRate 4x, , flex sdk.

2p.

,

+1

, , , , , , , . , .

, , , framecript ( , ) 10 100fps, , ( frameRate="100" mx:Application ).

+1

Source: https://habr.com/ru/post/1741817/


All Articles