Adobe Flex 3 Help

Considerations when using a Repeater component

Consider the following when you use a Repeater component:

  • You cannot use a Repeater component to iterate through a two-dimensional Array object that is programmatically generated. This is because the elements of an Array object do not trigger changeEvent events, and therefore cannot function as binding sources at run time. Binding copies initial values during instantiation after variables are declared in an <mx:Script> tag, but before initialize handlers are executed.
  • Run-time changes to an array used as a data provider are not reflected in the Repeater component. Use a collection if you need to allow run-time modification.
  • Forgetting curly braces ({ }) in a dataProvider property is a common mistake when using a Repeater component. If the Repeater component doesn't execute, make sure that the binding is correct.
  • If repeated objects are displayed out of order and you are using adjacent or nested Repeater components, you might need to place a dummy UIComponent immediately after the Repeater that is displaying objects incorrectly.

    The code in the following example contains adjacent <mx:Repeater> tags and uses an <mx:Spacer> tag to create a dummy UIComponent:

    <mx:VBox>
        <mx:Repeater id="r1">
            ...
        </mx:Repeater>
        <mx:Repeater id="r2">
            ...
        </mx:Repeater>
        <mx:Spacer height="0" id="dummy"/>
    </mx:VBox>
    
    

    The code in the following example contains nested <mx:Repeater> tags and uses an <mx:Spacer> tag to create a dummy UIComponent:

    <mx:VBox>
        <mx:Repeater id="outer">
            <mx:Repeater id="inner">
                ...
            </mx:Repeater>
            <mx:Spacer id="dummy" height="0">
        </mx:Repeater>
    </mx:VBox>