Hi,
You can use the following code to create a rectangle and insert a TextField into it. The user can type his data and the input can be captured as well. The rectangle can be dragged and dropped too.
private
{
ap.name =
"Rectangle"; var rect:Sprite = new Sprite(); rect.graphics.lineStyle(2, 0x990000, .75);rect.graphics.drawRect(50,50,150,100);
rect.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown) ;
rect.addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
rect.accessibilityProperties = ap;
var myTextBox:TextField = new TextField(); var myText:String = "Hello world and welcome to the show. It's really nice to meet you. Take your coat off and stay a while. OK, show is over. Hope you had fun. "; var wVal:Number = 130; var hVal:Number = 80;myTextBox.type = TextFieldType.INPUT;
myTextBox.background =
true;myTextBox.border =
true;myTextBox.width = wVal;
myTextBox.height = hVal;
myTextBox.borderColor = 0xFFFFFF;
myTextBox.x = 60;
myTextBox.y = 60;
myTextBox.wordWrap =
true;myTextBox.multiline =
true; if (Capabilities.hasAccessibility) {Accessibility.updateProperties();
}
var
format:TextFormat = new TextFormat();format.font =
"Verdana";format.color = 0xFF0000;
format.size = 10;
myTextBox.defaultTextFormat = format;
myTextBox.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownScroll);
myTextBox.addEventListener(TextEvent.TEXT_INPUT, textInputCapture);
function mouseDownScroll(event:MouseEvent):void{myTextBox.scrollV++;}rect.addChild(myTextBox);
myTextBox.text = myText;
function textInputCapture(event:TextEvent):void{var str:String = myTextBox.text;}var
uiComp: UIComponent = new UIComponent();uiComp.addChild(rect);
targetPanel.addChild(uiComp);
function mouseDown(event:MouseEvent):void {rect.startDrag();}
function mouseReleased(event:MouseEvent):void {rect.stopDrag();}
}
Regards,