1 Reply Latest reply on Oct 4, 2007 9:49 PM by Gregory Lafrance

    Problem CDATA

    FlyinArno
      hello
      I have this:

      <mx:TextArea id="lblValue" width="550" selectable="false" height="226">
      <mx:htmlText>
      <![CDATA[
      //String who contain html text
      ]]>
      </mx:htmlText>
      </mx:TextArea>
      I don't know how to bind the string and I can't do

      <mx:TextArea id="lblValue" width="550" selectable="false" height="226" htmlText="{String who contain html text}">

      If someone could help me

      Thanx
        • 1. Re: Problem CDATA
          Gregory Lafrance Level 6
          This code uses the <mx:Binding> tag:

          <?xml version="1.0"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
          <mx:Script>
          <![CDATA[
          public function changeText():void {
          lblValue.htmlText = "<b><i>Bold Italic Text</i></b>";
          }
          ]]>
          </mx:Script>

          <mx:Binding source="lblValue.htmlText" destination="lblValue2.htmlText"/>
          <mx:TextArea id="lblValue" width="550" selectable="false" height="226">
          <mx:htmlText><![CDATA[<b>Bold Text</b>]]></mx:htmlText>
          </mx:TextArea>

          <mx:TextArea id="lblValue2" width="550" selectable="false" height="226" htmlText="{lblValue.htmlText}"/>
          <mx:Button label="Change Text" click="changeText()" />
          </mx:Application>

          There are three ways around the problem of htmlText (from Flex 2 help docs):

          1) Set htmlText property in ActionScript method called as initialize handler. This is simplest approach because HTML markup remains readable. You must assign id to TextArea to refer to it in initialize handler.

          2) Specify htmlText property using child tag CDATA section.

          3) Use hmtlText attribute where any occurences of the HTML markup characters < and > in the attribute value are written instead as the XML "entities" &lt; and &gt;: Adobe does not recommend this approach because the HTML markup becomes nearly impossible to read.