7 Replies Latest reply on Jan 20, 2009 8:44 AM by rtalton

    Clearing TextArea text

    Mainmanian
      Attached below is a code that creates a TextArea and is programmed to clear the TextArea if the "enter" key is pressed. It does not seem to work well. The code shows a button control using the exact same call, but it works on that. Can someone please shed some light on this. Cheers

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application name="TextAreaClearText" xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical"
      verticalAlign="middle" backgroundColor="white">

      <mx:Script>
      <![CDATA[
      private function onKeyDown(e:KeyboardEvent):void{
      if (e.keyCode == Keyboard.ENTER){
      textArea.htmlText="";
      }
      }
      ]]>
      </mx:Script>

      <mx:Button label="Clear text"
      click="textArea.htmlText = '';" />
      <mx:TextArea id="textArea"
      textAlign="justify"
      width="10%"
      height="10%" keyDown="onKeyDown(event)"/>
      </mx:Application>