下面是页面加载的初始化方法
public function init(event:Event):void{
for(var i:int=0;i
if(“数学”==array[i].name){
subject.selectedIndex=i;
checkbox[i].selected=true;
}
}
}
这里我顺便把数学的复选框弄成了默认选中
看起来代码有点乱,下面我把整个页面代码都贴出来
xmlns:s=”library://ns.adobe.com/flex/spark”
xmlns:mx=”library://ns.adobe.com/flex/mx” minWidth=”955″ minHeight=”600″ initialize=”init(event)”>
import mx.controls.Alert;
public var all:String=””;
public var array:Array=new Array();
public function init(event:Event):void{
for(var i:int=0;i
if(“数学”==array[i].name){
subject.selectedIndex=i;
checkbox[i].selected=true;
}
}
}
//全选
private function checkAll():void{
for(var i:int=0;i
checkbox[i].selected=true;
all=all+checkbox[i].data+”,”;
}
Alert.show(“选择了:”+all.substr(0,all.lastIndexOf(“,”)));
all=””;
}
//全不选
private function checkNotAll():void{
for(var i:int=0;i
checkbox[i].selected=false;
}
}
//反选
private function reverse():void{
for(var i:int=0;i
if(checkbox[i].selected){
checkbox[i].selected=false;
}else{
checkbox[i].selected=true;
}
}
}
]]>
<IMG alt=”” src=”http://img.blog.csdn.net/20130706214231250?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hlbndpbGwz/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center”>