I don't know, how is exactly your component builded, you should have inner logic to resize subcomponents/childs.
Universal solution, blind resize of every child:
public function setWidth(w:Number):void
{
var i: uint, len: uint = this.numChildren, child: DisplayObject;
for(i; i < len; ++i){
this.getChildAt(i).width = w;
}
}
If only textArea is one child:
public function setWidth(w:Number):void
{
textArea.width = w;
}
Simple TextField container, with background and custom padding:
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
public class TextContainer extends Sprite {
private var _textField:TextField;
private var _padding:int;
public function TextContainer(text:String, format:TextFormat, padding:int = 4) {
_padding = padding;
_textField = new TextField();
_textField.defaultTextFormat = format;
_textField.autoSize = TextFieldAutoSize.LEFT;
_textField.multiline = true;
_textField.wordWrap = true;
_textField.text = text;
addChild(_textField);
_textField.x = _textField.y = padding;
//Default width
setWidth(100);
}
public function setWidth(value:Number):void {
_textField.width = value;
graphics.clear();
graphics.beginFill(0xF0F0F0);
graphics.drawRect(0, 0, _textField.width + 2*_padding, _textField.height + 2*_padding);
}
}
Usage:
var textContainer: TextContainer = new TextContainer("Some text here for test, more text, for multi-line test and resize", new TextFormat("Arial"));
desiredContainer.addChild(textContainer);
textContainer.setWidth(200);