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
"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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With