all groups > flash actionscript > september 2004 >
You're in the

flash actionscript

group:

Textfield


Textfield alejandrolaplata
9/30/2004 11:46:30 PM
flash actionscript:
Here's the problem:
I have a dynamic text field with a text format that's not uniform. How can I
add new text without loosing its previous format? I can't work it out without
using html. I need some help.
Re: Textfield _jrh_
10/1/2004 12:17:51 AM
Re: Textfield alejandrolaplata
10/1/2004 12:51:54 AM
No, it should'nt reformat it, but when format is not uniform it does.
Here's an example:

myText.html=false;
myText.text = "ABCDEFGHIJKLMNOPQRSTUVWXZ";
myTextFormat = new TextFormat();
myTextFormat.bold = true;
myText.setTextFormat(1,15,myTextFormat);
myText.text += "0123456789"; / At this point the previous format is lost.

Re: Textfield _jrh_
10/1/2004 1:15:26 AM
Here's an ugly way of doing it but the only way without reformatting the field.
Once you add text, any formatting that was applied with setTextFormat is
destroyed.

myTextFormat = new TextFormat();
myTextFormat.bold = true;

myText.text = "ABCDEFGHIJKLMNOPQRSTUVWXZ";
myText.setTextFormat(0,15,myTextFormat);

Selection.setFocus(myText);
Selection.setSelection(myText.length,myText.length);
myText.replaceSel("0123456789");
Re: Textfield alejandrolaplata
10/1/2004 3:20:51 AM
Re: Textfield _jrh_
10/1/2004 3:33:55 AM
AddThis Social Bookmark Button