actionscript-3textareaflash-10

click on color button and write in textarea with that color font


I want to do as follows:

* click a "red" button
* write in textarea with red color font
* click "blue" button
* write in textarea with blue color font

Isn't this possible in flash 10 using AS3 ??????

I tried using setTextFormat but the problem is i have to have text before inserting format on that.

This is what i want:

* start writing in textarea with WHITE COLOR (eg: "abc")
* click BLUE COLOR BUTTON
* start writing in textarea with BLUE COLOR (eg: "abcdef" - abc in white and def in blue)
* click RED COLOR BUTTON
* start writing in textarea with RED COLOR (eg: "abcdefxyz" - abc in white and def in blue and xyz in red)

Please somebody tell me how to do this?


Solution

  • Here is the solution for anyone who is looking around (thanks to those who solved my problem)

    Use following in changehandler of textfield:

    textfield.setTextFormat(default_format, textfield.caretIndex-1, textfield.caretIndex);
    

    Use following in clickhandler of button:

    default_format.color = getColor("red");
        stage.focus = textfield;
    

    Regards