[flashpro] Strange problem with TextField & TextFormat

Gunther Konig nitchcock at gmail.com
Sat Feb 26 18:59:56 EST 2005


Hi,

First of all: hope I'm not enterupting anything. Seen the list's been
really quite in the past few... (weeks, months...)

I have a very strange problem. For the sake of simplicity I've reduced
the code. Place the following sequence in the first frame of a new
movie:

//create a new input text field
_root.createTextField('txt',_root.getNextHighestDepth(),0,0,150,100);
txt.type = 'input';
txt.text = '012';
txt.multiline = true;
txt.wordWrap = true;
txt.border = true;

//assign a simple TextFormat to *one* character
my_fmt = new TextFormat();
my_fmt.bold = true;
txt.setTextFormat(1, my_fmt);

//add a character after the caret
txt.onChanged = function(t){
	begin = t.text.slice(0, Selection.getBeginIndex());
	end = t.text.slice(Selection.getEndIndex());
	t.text = begin+'|'+end;
}

If you run the movie, place the caret *before* character 1, and then
type something, the whole format of the input is changing (to bold).
Does this have any logic explanation?

All I'm thinking of: placing the carot before bolded "1" means that
the new chars (typed by the user) will inherit its format (in our case
just bold). Then AS creates another character, between the two bolded
ones. However, this doesn't explain why all characters turn bold.

Regards
GK


More information about the FlashPro mailing list