Skip to main content
March 2, 2010
Question

i couldnt change source property of string with a variable :s

  • March 2, 2010
  • 1 reply
  • 500 views

i have an if block, and i want to change the content of the richtext according to result of the if situation, but it doesnt accept source with a variable, or i couldnt :s

<s:RichText

x="28" y="51" width="460">

<s:text>

<fx:String id="metin" source="how to define with a variable?"/>

</s:text>

</s:RichText>

This topic has been closed for replies.

1 reply

Adobe Employee
March 3, 2010

I think if you set it up something like this it should work better:

<RichText>

     <content>

          <TextFlow>

               <p>Product #<span id="prodNum">0000</span></p>

          </TextFlow>

     </content>

</RichText>

Then in your script, you can do something like this:

     prodNum.text = productNumber.toString();

Alternatively, you can set it up using a binding:

<RichText>

     <content>

          <TextFlow>

               <p>Product #<span>{productNumber}</span></p>

          </TextFlow>

     </content>

</RichText>

I don't have the exact code in front of me, so there may be some errors here, but I think the basic ideas should work.
Thanks,
- robin

March 3, 2010

thanks robin, its ok!

import

flashx.textLayout.conversion.TextConverter;

[

Bindable]

public var txtdegiskeni:Object;

<fx:Declarations>

<fx:String id="txtyol1" source="Metinler/geneltanitim.txt" />

<fx:String id="txtyol2" source="Metinler/tarihce.txt" />

</fx:Declarations>

txtdegiskeni=txtyol1;

txtdegiskeni=txtyol2;

<s:RichText

top="45" textFlow="{TextConverter.importToFlow(txtdegiskeni,TextConverter.HTML_FORMAT)}"/>