How to set Cursor in TextField?

In ActionScript 3, when you change the value of a TextField, why do you lose the TextFormat associated with the TextField?

  • I set a new value to my TextField and the TextFormat is lost. I need to reset it after changing the value. Is this normal?

  • Answer:

    It's also not too hard to just grab the TextFormat in use and reapply it after you update the text: (assuming that myTextField is your text field in use): var myTextFormat:TextFormat = myTextField.getTextFormat(); // get original text formatting myTextField.text = myValue; // apply new text myTextField.setTextFormat(myTextFormat); // re-apply the original text formatting

Eric Oliver at Quora Visit the source

Was this solution helpful to you?

Other answers

Here's another workaround: assign the defaultTextFormat value for the TextField. Note that the defaultTextFormat won't come into effect before the next assignment of the TextField.text value.

Yingnan Song

This is completely normal and is one of the quirks of AS3.  I ran into a problem of the text in the field completely disappearing when rotated.  As others suggested, save the textformat, and then reapply it.

Toan Tran

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.