1 Reply Latest reply on Aug 23, 2009 10:04 PM by Flex harUI

    Problem with an 'if' statement

    SiHoop Level 1

      I am unable to get a match on the 'if' statement shown in the code below (i.e.  if(textAreaContent.text==textAreaText)). However, if I change

      private var textAreaText:String="Enter \nhere."

      to

      private var textAreaText:String="Enter here."

      it works.

      Clearly, it is related to \n, but how I can make the if-statement work without removing the \n?

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()">
      <mx:Script>
      <![CDATA[
      private var textAreaText:String="Enter \nhere."
      private function init():void{
          textAreaContent.text=textAreaText
      }
      private function passageFocusReceived(event:Event) : void{
          if(textAreaContent.text==textAreaText){
              event.currentTarget.text=""
          }
      }
      ]]>
      </mx:Script>
              <mx:TextArea id="textAreaContent" focusIn="passageFocusReceived(event)" />
      </mx:Application>