<?xml version="1.0"?>
<!-- repeater/StaticLoop.mxml -->
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns="*">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
[Bindable]
public var myArray:Array=[{'disname':'高血压','isno':'1'},{'disname':'糖尿病','isno':'0'}];
protected function button1_clickHandler(event:MouseEvent):void
{
trace(myArray[0].isno);
// update()
}
protected function radioButtonevent(e:Event):void{
var radio:RadioButton = RadioButton(e.currentTarget);
var item:Object = radio.getRepeaterItem();
if(radio.data=='0')item.isno='1';
}
protected function checkbox1_changeHandler(e:Event):void
{
var chbox:CheckBox = CheckBox(e.currentTarget);
var item:Object = chbox.getRepeaterItem();
if(chbox.data=='0')item.isno='1';
if(chbox.data=='1')item.isno='0';
}
]]>
</fx:Script>
<fx:Declarations>
<mx:ArrayCollection id="myAC" source="{myArray}"/>
</fx:Declarations>
<!-- Notice that the Repeater is inside a MX container. -->
<mx:VBox>
<mx:Repeater id="myrep" dataProvider="{myAC}">
<mx:RadioButton label="{myrep.currentItem.disname}" data="{myrep.currentItem.isno}"
selected="{myrep.currentItem.isno =='1'}" change="radioButtonevent(event)"/>
</mx:Repeater>
<mx:Repeater id="myrep2" dataProvider="{myAC}">
<mx:CheckBox label="{myrep2.currentItem.disname}" data="{myrep2.currentItem.isno}"
selected="{myrep2.currentItem.isno == 1}" change="checkbox1_changeHandler(event)"/>
</mx:Repeater>
</mx:VBox>
<s:Button label="更新" click="button1_clickHandler(event)"/>
</s:Application>