Using the Repeater class in Flex 4

The following example shows how you can use the Repeater class with Flex 4. The trick to using the Repeater class in Flex 4 is that the repeater must be within an MX container (HBox, VBox, Canvas, mx:Panel, mx:Application, etc).

The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see To download the latest nightly build of the Flex 4 SDK, see

For more information on getting started with Flex 4 and Flash Builder 4, see the official Adobe Flex Team blog.

<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<s:Application name="Spark_Repeater_test"
        <s:ArrayList id="arrList"
    <s:VGroup horizontalCenter="0" verticalCenter="0">
        <s:Label text="-- Start" />
            <mx:Repeater id="r" dataProvider="{arrList}">
                <s:Button left="20" top="335" label="{r.currentItem}" />
        <s:Label text="Finish --" />


View source is enabled in the following example.

This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.

3 thoughts on “Using the Repeater class in Flex 4

  1. Do you know if a repeater has to have a dataProvider or will the count property suffice? I’m not having any luck getting a simple repeater to add multiple children into my container in Flex 4. I don’t need a DP.

  2. Do repeaters show visually in Design View in Gumbo? I can’t seem to get the repeater content to show while in FB3 there was a preview.

    Example code,

    	<mx:VBox id="contentVBox0" verticalGap="0" left="0" y="0" width="400">
    		<mx:Repeater id="postsRepeater" dataProvider="{}" width="100%" x="0" y="0">
    			<mx:VBox id="contentVBox3" width="100%" verticalGap="0">
    				<mx:Canvas id="canvas0" width="100%" >
    					<mx:Text id="textlink0" text="Post Title" height="26" styleName="postTitle"
    						htmlText="{postsRepeater.currentItem.@title}" fontSize="19" fontWeight="bold"/>
    					<mx:Text id="textautosize0" y="25" selectable="true" styleName="postDateCreated" text="Saturday, January 1, 2009"
    						htmlText="{postsRepeater.currentItem.dateCreated}"  fontWeight="bold"/>
    					<mx:Text id="postDescription0" width="100%" y="52" styleName="postDescription" text="Description area"
    				<mx:Spacer id="spacer0" height="35" />
  3. Hi,
    How do I assign an id dynamically? I’m building a form with dynamic fields and need to then read the values to send to PHP.



Comments are closed.