Does the repeat event for a repeater fire for each item in the dataprovider? That is the way that I read it, but it does not appear to be functioning that way. I want to trigger a function for each iteration of the repeater that sets some variable values to be used by the components inside the repeater. Is there a way to do this?
My code is attached.
Comments
You are correct, the repeat event is fired for each item in the data provider.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
[Bindable]
private var ary:XML =
<root>
<item name="Red"/>
<item name="Green"/>
<item name="Blue"/>
</root>
private function onRepeat(val:Object):void
{
trace(val);
}
]]>
</mx:Script>
<mx:Repeater id="rptTest" dataProvider="{ary..item}" repeat="{onRepeat(rptTest.currentItem)}">
<mx:ComboBox text="{rptTest.currentItem.@name}"/>
</mx:Repeater>
</mx:Application>
I set up this simple app to demo the process. Each time the repeater has updated the currentItem and currntIndex property, the event is triggered and stepping through will allow you to see that calling of the function is executed. What is your app doing/not doing? It might simply be a matter of scope for the values you are trying to set. For example, if your partnerItem is set inside of the function, it wont be available once the function returns. Have you tried moving the vars up to the application and then setting the values inside the function to be available for each iteration? This might help.