Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 815
Hichem MHAMED Avatar asked Jul 10 '26 12:07

Hichem MHAMED


1 Answers

"But i still wonder if it is possible to be handled directly in mxml ? Especially if the binded variable changes i need it to be updated in the text component."
Hichem

You can bind the property to a function call so that whenever the bound value changes the result of the function call is used as the value to htmlText:

<mx:Script>
<![CDATA[

    function sayHello(userName:String):String
    {
        var text:String = "<![CDATA[<img src='assets.OrangeRect' align='left' hspace='0' vspace='4'/>    Bonjour " + userName + " ]]>";
        return text;
    }

]]>
</mx:Script>

<mx:Text id="bodyText" styleName="bodyText" htmlText="{sayHello(UserData.name)}" />

This is like a combination of the two - specify your binding in MXML, but have the value generated in the scripting section.

like image 185
Sly_cardinal Avatar answered Jul 13 '26 16:07

Sly_cardinal