Skip to main content
Inspiring
October 21, 2009
Answered

How do I assign a textflow in a repeater?

  • October 21, 2009
  • 1 reply
  • 910 views

I'm trying to set a RichEditableText dynamically in a repeater and I need help.

If I set the content property the images don't show up and I think it just shows the raw markup. I tried assigning it to the textFlow property and I get errors.

Shows raw markup:

<mx:Repeater id="postsRepeater" dataProvider="{XML(content1.lastResult).posts.post}" width="100%" x="0" y="0">
                                    <mx:VBox id="contentVBox3" width="450" verticalGap="0" verticalScrollPolicy="off" horizontalScrollPolicy="off">
                                             <s:RichEditableText width="100%" y="52" styleName="postDescription" text="Description area"
                                                                editable="false" lineBreak="toFit" content="{String(XML(postsRepeater.currentItem).content)}">
                                            </s:RichEditableText>

                                    </mx:VBox>

</mx:Repeater>

Throws Errors:

<mx:Repeater id="postsRepeater" dataProvider="{XML(content1.lastResult).posts.post}" width="100%" x="0" y="0">
                                     <mx:VBox id="contentVBox3" width="450" verticalGap="0" verticalScrollPolicy="off" horizontalScrollPolicy="off">
                                              <s:RichEditableText width="100%" y="52" styleName="postDescription" text="Description area"
                                                                 editable="false" lineBreak="toFit" textFlow="{String(XML(postsRepeater.currentItem).content)}">
                                             </s:RichEditableText>

                                    </mx:VBox>

</mx:Repeater>

1067: Implicit coercion of a value of type String to an unrelated type flashx.textLayout.elements:TextFlow.

This topic has been closed for replies.
Correct answer GordonSmith

Using a Spark DataGroup is more efficient than using a Repeater, so my advice is to stop using Repeater. But your main issue is about how to set the textFlow property. If you have a String containing TLF markup, then you can convert it to a TextFlow using TextFlowUtil.importFromString().

Gordon Smith

Adobe Flex SDK Team

1 reply

thx1138Author
Inspiring
October 21, 2009

I have also tried:

<s:RichEditableText width="100%" y="52" styleName="postDescription" text="Description" editable="false" lineBreak="toFit">
            <s:TextFlow>{String(XML(postsRepeater.currentItem).content)}</s:TextFlow>
</s:RichEditableText>

Which throws this error:

Unable to generate initialization code within Repeater, due to id or data binding on a component that is not a visual child

GordonSmithCorrect answer
Participating Frequently
October 21, 2009

Using a Spark DataGroup is more efficient than using a Repeater, so my advice is to stop using Repeater. But your main issue is about how to set the textFlow property. If you have a String containing TLF markup, then you can convert it to a TextFlow using TextFlowUtil.importFromString().

Gordon Smith

Adobe Flex SDK Team

thx1138Author
Inspiring
October 21, 2009

Ah thanks. Will update that.