Change text color by selecting text

I would like to be able to select text in a text box and change only the selected text color. There would be a selection of colors you could choose from in a listbox. So select a chunk of text and then select the color you want for the text in a listbox.

Can this be done?
If so, where do I start?

OK, I assume that by the silence of this post what I am asking cannot be done.

So I’ll ask something slightly different.

Say I am adding text to a textplate via action script. On a button I have this;

textplate += “Hello”

This puts the word hello in the text box. Great, but it always puts the text at the very end of the text file. I would like it when you hit the button to add the word hello to the textplate, the word would appear where the curser is.

What you were first asking is definitely doable. Take a look at the AS Dictionary, textField methods. TextField.replaceSel( text ) looks nice for instance :slight_smile:

Yup… Check out Selection.getCaretIndex() also… I see that it is abit more difficult than you this in Java though…

I’ve never seen this method before, and you probably haven’t either, that’s why you NEED TO CHECK THE AS DICTIONARY AT SELECTION AND TEXTFIELD!! :beam: :beam:

Yup… I’ve been using Flash since F4, and I still got lots of places which WOWs me alot and which puzzles me many times… DO read the Flash manual as much as you can and try to understand it… You don’t have to read your car manual to drive the car, but to tweak your car, you will have to read and understand the manual… Don’t you think so??? Also, do the searching on the forum with some clues you find during the reading to get more information… :wink:

This definitely opens up some options.

Keep it posted… You grabbed my attention… :wink:

In this FLA select the text box and write something in it. Next, make sure you leave the curser at the end of your text and hit the black button.

You will notice that the text is inserted at the beginning of the text box. Even if you highlight some of the text and then hit the black button the text inserts itself at the beginning of the text box.

I think I know what the problem is, but I don’t know how to fix it.
When you leave the curser at the end of you text you will notice the output window will be >-1 ,but as soon as you hit the button to invoke the replaceSel command the output window says -1.
This means that the listbox is not selected when you hit the button.

You’ll see what I mean.


Try this file…