Thursday, March 31, 2011

Repeater Referencing repeated components

To reference individual instances of a repeated component, you use indexed id references, as the following example shows:

<?xml version="1.0"?> 
<!-- repeater\RefRepeatedComponents.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        <![CDATA[

            public function labelTrace():void {
                for (var i:int = 0; i < nameLabel.length; i++)
                    trace(nameLabel[i].text);
            }
        ]]>
    </mx:Script>

    <mx:Model id="catalog" source="../assets/repeater/catalog.xml"/>
    <mx:ArrayCollection id="myAC" source="{catalog.product}"/>
    <mx:Label id="title" text="Products:"/>
    
    <mx:Repeater id="r" dataProvider="{myAC}" startingIndex="1">
        <mx:Label id="nameLabel"
            text="{r.currentItem.name}: ${r.currentItem.price}"
            width="200"/>
    </mx:Repeater>
    <mx:Button label="Trace" click="labelTrace();"/>
</mx:Application>
 
For More Details Visit : http://livedocs.adobe.com/flex/3/html/help.html?content=repeater_3.html 

No comments:

Post a Comment