flex项目总结

一、flex端session超时检测
this.systemManager.addEventListener(FlexEvent.IDLE, userIdle);

private function userIdle(e:FlexEvent):void {
	    if(e.currentTarget.mx_internal::idleCounter == 6000){//十分钟没有操作就自动跳到登陆页面
	    	logout();
	   } 
	}


二、datagrid潜入checkbox使用
private var selecetedIndex:Array = [];//设置选中行

/*选中行*/
public function clickColum(e:Event):void{
	chooseSelected();
}

private function chooseSelected():void{
	this.userEquipData.selectedItem.flag = !this.userEquipData.selectedItem.flag;
	for(var i:int = 0;i<userEquiplist.length;i++){
		if(userEquiplist[i].flag == true){
			selecetedIndex.push(i);
		}
	}
	userEquipData.selectedIndices = selecetedIndex;
}
/*选中行绑定选中行的flag*/
public function clickCheckbox(event:Event,obj:Object):void { 
    //调整按钮选择性 
    this.unAll.selected = false; 
    this.all.selected = false; 
    //在单向绑定时可采用此法将选中信息反应到数据源 
    obj.flag =  CheckBox(event.target).selected;
    
    chooseSelected();
}
/* 
 *实现所有项目的全选中过程  
*/ 
public function all_click(event:Event):void{
    userEquiplist = this.userEquipData.dataProvider as ArrayCollection;
    this.unAll.selected = false;
    for(var i:int = 0 ;i<userEquiplist.length;i++){
        userEquiplist[i].flag = CheckBox(event.target).selected;
        if(userEquiplist[i].flag == true){
	        selecetedIndex.push(i);
        }
    }
    userEquipData.selectedIndices = selecetedIndex;
}
/* 
 *实现项目反相选中 
*/ 
public function unAll_click(event:Event):void{
    if(CheckBox(event.target).selected){
        this.all.selected = false;
        userEquiplist = this.userEquipData.dataProvider as ArrayCollection;
        for(var i:int = 0 ;i<userEquiplist.length;i++){
            userEquiplist[i].flag = !userEquiplist[i].flag;
             if(userEquiplist[i].flag == true){
		        selecetedIndex.push(i);
	        }
        }
        userEquipData.selectedIndices = selecetedIndex;
    }
}

/*下发用例到UE*/
private function downSelectedUE(isDO:int):void{
	var ac:ArrayCollection = this.userEquipData.dataProvider as ArrayCollection;
    var selectedNames:String = "选中项目名称为:";
    var selectedUeIds:String = "";
    
    for(var i:int = 0;i<ac.length;i++){
        if(ac[i].flag == true){
            selectedNames += ac[i].ueId + "设备号码" + ac[i].ueNo;
            selectedUeIds += ac[i].ueId + ",";
        }
    }
    if(selectedUeIds.split(",").length < 2){
    	Alert.show("请选择要下发的UE");
    	return;
    }
    userCaseAction.downUserCase(ucId,selectedUeIds,isDO);
}


flex界面
<mx:DataGridColumn headerText="选择" textAlign="center">
     <mx:itemRenderer>
           <mx:Component >
               <mx:HBox horizontalAlign="center">
                   <mx:CheckBox selected="{data.flag}" click="outerDocument.clickCheckbox(event,data)" width="13"/>
               </mx:HBox>
           </mx:Component>
     </mx:itemRenderer>
</mx:DataGridColumn>


三、flex使用全局变量
/*跟踪用例*/
public function followUserCase(obj:Object):void{
    Application.application.userCaseId = obj.ucId;
    Application.application.moduleLoad.unloadModule();
    Application.application.moduleLoad.url = 'module/caseresult/caseresult.swf';
    Application.application.moduleLoad.loadModule();
}


你可能感兴趣的:(java,UI,Flex)