下面的例子展示了如何通过监听TextArea的textInput事件和检查TextEvent对象的text属性,来截获该控件中按下的回车换行。 下面是具体的源代码: main.mxml <!-- http : //blog.flexexamples.com/2008/03/07/preventing-line-feeds-in-a-textarea-control-in-flex/ --> < mx : application xmlns : mx = " http://www.adobe.com/2006/mxml " > layout = " vertical " verticalAlign = " middle " backgroundColor = " white " & gt ;< / mx:application> <mx:script> <!--[CDATA[ private function textArea_textInput(evt:TextEvent):void { if (evt.text == "\n") { evt.preventDefault(); } } ]]--> < / mx : script > < mx : textarea id = " textArea " > verticalScrollPolicy = " on " width = " 160 " height = " 120 " textInput = " textArea_textInput(event); " & gt ; < mx : text > The quick brown fox jumped over the lazy dog .< / mx:text> < / mx : textarea > 下面是执行实例: 转:http://blog.minidx.com/2008/03/09/556.html