Fahim Akhter
Fahim Akhter

Reputation: 1625

Changing color of particular text in a text field

Consider I have the text

A quick brown fox jumps over the lazy dog.

Now, this text is in a dynamic text field. I do not want to change the color of the whole field. just made fox red and dog blue.

How, can I do that in AS3. Have been looking around without no luck.

Thanks

Upvotes: 1

Views: 3573

Answers (2)

Afra
Afra

Reputation: 2592

When you use the method myTextField.setTextFormat() you can add arguments to it to specify what part of the String that it should apply to.

F.e.

myTextField.setTextFormat (myFormat, 5, 8);

will apply to characters 5-8.

So what you need to do is to make a new TextFormat with the color you want and setTextFormat() those characters.

Upvotes: 10

Angelo
Angelo

Reputation: 1656

You can use some HTML tags to format the text (or subset of it) inside your textField.

Upvotes: 0

Related Questions