我正在使用一个Flex4mxml文件,该文件使用RichEditableText的textFlow,如下所示:
<s:RichEditableText>
<s:textFlow>
<s:TextFlow>
<s:p>Here is your result: {myVariable}</s:p>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>middleTier返回myVariable,等于字符"a“、"b”或"c“。但是,由于我需要根据字符显示一条消息,因此我想调用一个actionscript函数来解码myVariable。例如:
private function myFunction(myVariable):String {
if (myVariable=="a")
myMsg = "You selected letter a";
else if (myVariable=="b")
myMsg = "You selected letter b";
else
myMsg = "You selected letter c";
return myMsg;
}我不确定该怎么做,但我尝试了以下方法:
<s:RichEditableText>
<s:textFlow>
<s:TextFlow>
<s:p>Here is your result: {myFunction(myVariable)}</s:p>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>尽管它编译良好并运行,但结果是--没有显示任何内容,甚至Here is your result:文本也没有显示。
你知道怎么做到这一点吗?或者,如果不能从<s:p> ... </s:p>内部调用actionscript函数,那么可以使用内联(有时称为速记) if / then /ElseActionScript语句来实现吗?
感谢您的评论。
发布于 2012-06-20 09:32:29
您可以在此链接http://blog.flexexamples.com/2009/10/09/dynamically-adding-paragraphs-to-a-spark-richtext-control-in-flex-4/中添加文本
https://stackoverflow.com/questions/11111609
复制相似问题