SingleMutiLineTextArea.aspackage components
{
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.TextEvent;
import flash.ui.Keyboard;
import mx.controls.TextArea;
public class SingleMutiLineTextArea extends TextArea
{
public function SingleMutiLineTextArea()
{
super();
this.addEventListener(TextEvent.TEXT_INPUT,onTextInput);
}
private var _multiLine:Boolean = false;
public function set multiLine(value:Boolean):void
{
multiLine = value;
}
public function get multiLine():Boolean
{
return _multiLine;
}
private function onTextInput(event:TextEvent):void
{
if (!_multiLine && (event.text.charCodeAt() == 10 || event.text.indexOf(String.fromCharCode(10))!=-1))
{
event.preventDefault();
}
}
}
}
If the property 'multiLine' is set to 'true' it accepts multiline entering of text., if it is set to 'false' it wont allow.
Leave you comments below if found useful