[flashpro] Strange problem with TextField & TextFormat
Muzak
p.ginneberge at pandora.be
Sun Feb 27 06:46:32 EST 2005
from the manual:
<quote>
TextField.setTextFormat()
Notice that any text inserted manually by the user, or replaced by means of TextField.replaceSel(), receives the text field's
default formatting for new text, and not the formatting specified for the text insertion point. To set a text field's default
formatting for new text, use TextField.setNewTextFormat().
</quote>
regards,
Muzak
----- Original Message -----
From: "Gunther Konig" <nitchcock at gmail.com>
To: <flashpro at muinar.org>
Sent: Sunday, February 27, 2005 12:59 AM
Subject: [flashpro] Strange problem with TextField & TextFormat
> 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