I'm trying to use a repeater to configure n different bars in a foo
(e.g., in pseudo-code
foo
bars:Array = [ { bar1, bar2, bar3 ];
...
where each bar is something like
bar
label:String
baz:String
...
)
each of the bars has a baz that can be one of five different Strings. My
current approach is to use a repeater:
<mx:Script>
<![CDATA[
protected function handleBarBoxInit(e:Event):void {
var barBox:ComboBox = e.currentTarget as ComboBox;
var bazArray:Array = getValidBazes(barRptr.currentItem);
barBox.dataProvider = bazArray;
barBox.selectedIndex = bazArray.indexOf(barRptr.currentItem.baz);
}
]]>
</mx:Script>
....
<mx:Repeater id="barRptr" dataProvider="{dataProvider.bars}">
<mx:FormItem label="{'Change baz of bar \'' + barRptr.currentItem.label
+ '\' to '}">
<mx:ComboBox initialize="handleBarBoxInit(event)"/>
</mx:FormItem>
</mx:Repeater>
...
This works very nicely for displaying the correct controls with the
current baz of each bar, but I'm not sure how to come up with a clean
way to "harvest" the settings of each combobox when updating the set. I
don't want to directly listen to each ComboBox CHANGE event because I
want to have update/cancel functionality for the entire group. Is there
a way of doing this cleaner than iterating over the children of barRptr
(presumably FormItems) and doing getChildAt(0) to get the ComboBoxes?
Thanks,
--
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com