apache-flex - 如何在 htmltext CDATA 中进行绑定(bind)

标签 apache-flex actionscript-3 actionscript cdata

我找不到在 Text 组件的 htmlText 属性中绑定(bind)变量的方法 我希望能够做这样的事情:

<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>

我想绑定(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

您可以将属性绑定(bind)到函数调用,这样每当绑定(bind)值发生变化时,函数调用的结果就用作 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 中指定您的绑定(bind),但在脚本部分生成值。

关于apache-flex - 如何在 htmltext CDATA 中进行绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2470360/

相关文章:

apache-flex - Linux下ActionScript3字体编译转码错误

actionscript-3 - as3 转码器 mimetypes

apache-flex - 访问 DataGrid 中的 ItemRenderer

linux - Firefox、Linux 中的 Flash 跟踪输出

apache-flex - 弹性树拖放

JQuery:有没有办法进行 Flex 风格的数据绑定(bind)?

html - 这些 Flash 颜色值的颜色格式/编码是什么

actionscript-3 - 如何无缝循环FLV

javascript - 以对象作为键(不是字符串而是唯一对象)的关联映射的 javascript 方法是什么?

apache-flex - Flex : selectable text in DataGridColumn?