I’m working with a Flex 4 mxml file that uses a textFlow for RichEditableText as follows:
<s:RichEditableText>
<s:textFlow>
<s:TextFlow>
<s:p>Here is your result: {myVariable}</s:p>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>
myVariable is returned from the middleTier, and equals character “a”, “b”, or “c”. But since I need to display a message depending on what the character is, I want to call an actionscript function to decode myVariable. For example:
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;
}
I’m not sure how to do this, but I tried the following:
<s:RichEditableText>
<s:textFlow>
<s:TextFlow>
<s:p>Here is your result: {myFunction(myVariable)}</s:p>
</s:TextFlow>
</s:textFlow>
</s:RichEditableText>
Although it compiled fine and ran, the result was — nothing got displayed, not even the Here is your result: text.
Any idea how to achieve this? Alternatively, if it’s not possible to call an actionscript function from inside the <s:p> ... </s:p>, then can this be achieved using an inline (sometimes called shorthand) if/then/else actionscript statement?
Thanks for any comments.
You can add text dynamically.refer this link http://blog.flexexamples.com/2009/10/09/dynamically-adding-paragraphs-to-a-spark-richtext-control-in-flex-4/