Selecting and formatting text

Hi all,

I’m currently looking into selecting and formatting text but I think I need someone to point me in the right direction.
What I would like to achieve is this :

So after clicking the button:
the text “This selected…” should be red. Only red in the output box would be ok too, but preferably in both.

The input text is an input textfield and the output a dynamic textfield.
I have been looking into TextSnapshot but this only seems to apply to static text. Using the htmlText property I could input a string with html tags but that’s gonna be complicated I guess. Is there any way of achieving this using TextField.setTextFormat() ?

Thanx in advance.