Search code examples
apache-flexactionscript-3actionscriptcdata

How to do binding inside htmltext CDATA


I couldn't find a way to bind a variable inside the htmlText property of a Text component i want to be able to do something like this :

<mx:Text id="bodyText"  styleName="bodyText">
<mx:htmlText >
    <![CDATA[<img src='assets.OrangeRect' align='left' hspace='0' vspace='4'/>    Bonjour {UserData.name} ]]>

    </mx:htmlText>
</mx:Text>

i want to bind UserData.name


Solution

  • I'm not sure how it would be handled in MXML, but you can generate the full string in Actionscript:

    bodyText.htmlText = "<![CDATA[<img src='assets.OrangeRect' align='left' hspace='0' vspace='4'/>    Bonjour " + UserData.name + " ]]>";