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
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
Related Q & A:
- How do I change the value of an attribute?Best solution by Stack Overflow
- How to change input value in formly?Best solution by Stack Overflow
- What are the points for and why do you lose them when you ask a question?Best solution by Yahoo! Answers
- Why my car feels like it wants to shut off when I start the engine it a Ford Focus 2003?Best solution by Yahoo! Answers
- Of what value to a plant is the ability to lose water through transpiration?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.