How to bind inside htmltext CDATA

I could not find a way to bind the variable inside the htmlText property of the Text component. I want 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

+3
source share
2 answers

I'm not sure how this will be handled in MXML, but you can generate a full line in ActionScript:

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

"But I'm still wondering if it can be processed directly in mxml? Especially if the variable with the binding changes, I need it to be updated in the text component."
Hichem

, , , 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)}" />

- MXML, , .

+5

Source: https://habr.com/ru/post/1737527/


All Articles