Search code examples
actionscript-3flashtextareacomponentstextformat

how do I change a TextArea component's font size in Flash using AS3?


I want to change the font size of Flash's TextArea component which is currently on the stage using AS3.

I tried linking a TextFormat object to the TextAera by its instance name, but I get this error:

Scene 1, Layer 'actions', Frame 1, Line 44  1061: Call to a possibly undefined method setTextFormat through a reference with static type fl.controls:TextArea.

Here is the AS3 code:

var myTextFormat:TextFormat = new TextFormat();

myTextFormat.font = "Arial";
myTextFormat.size = 10;
myTextFormat.color = 0xffffff;

my_textArea.setTextFormat(myTextFormat)

Solution

  • Try this snippet:

    myTextArea.setStyle("textFormat", myTextAreaFormat);