Revision: 27189
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 27, 2010 06:28 by adrianparr
Initial Code
import flash.text.TextFormat; import fl.controls.TextArea; import flash.events.Event; var myTextArea:TextArea = new TextArea(); myTextArea.setSize(200, 100); myTextArea.text = "Hello World"; var myTextFormat:TextFormat = new TextFormat(); myTextFormat.font = "Arial"; myTextFormat.size = 22; myTextFormat.bold = false; myTextFormat.italic = false; myTextFormat.underline = false; myTextArea.setStyle("textFormat", myTextFormat); myTextArea.x = 30; myTextArea.y = 30; addChild(myTextArea); myTextArea.setStyle("focusRectSkin",Sprite); myTextArea.addEventListener(Event.CHANGE, onMyTextArea_CHANGE); function onMyTextArea_CHANGE(event:Event) { myTextArea.text = myTextArea.text.replace("\r", ""); }
Initial URL
http://stackoverflow.com/questions/1239891/as3-textarea-component-disallow-user-to-enter-a-line-break
Initial Description
There is no built-in way of preventing the user pressing the Enter Key in a TextArea Component (in a standard TextField you can set multiline = false). Instead, you need to listen for the CHANGE event and then remove the Carriage Retun (\r) character.
Initial Title
AS3 Prevent Multiline in TextArea Component
Initial Tags
Initial Language
ActionScript 3