Dynamically change color of selected text

Hi,

how can I change the color of a selected piece of text dynamically?

I tried somethings like this (the function is called by a button):

function changeColor() {
    Selection.setFocus(textFieldname);
    Selection.setSelection(begin, end);
        sel = textFieldname.text.slice(begin, end);
    sel.textColor = "0xFF0000";
}

but I guess ‘sel’ isn’t a string, so i can’t add textColor to it?

Adding something like:

sel = new String(begin, end);

doesn’t help much.

thank you,

Jerryj.

Hi,
Did you ever get this to work? I’m trying it with that code and can’t get it to work. Could you post the code up again?