zoukankan      html  css  js  c++  java
  • FLEX,图标操作,xml, 通信,实例

    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    				layout="absolute"
    				verticalAlign="middle"
    				backgroundColor="white"
    				initialize="init()">
    	<mx:LineChart id="lineChart"
    				  showDataTips="true"
    				  width="462"
    				  height="342"
    				  seriesFilters="[]" x="10" y="141">
    		<!--showAllDataTips="true"-->
    		<mx:backgroundElements>
    			<mx:GridLines horizontalTickAligned="true" verticalTickAligned="true">
    				<mx:horizontalFill>
    					<mx:SolidColor color="haloBlue" alpha="0.2" />
    				</mx:horizontalFill>
    				<mx:horizontalAlternateFill>
    					<mx:SolidColor color="haloSilver" alpha="0.2" />
    				</mx:horizontalAlternateFill>
    				<mx:verticalFill>
    					<mx:SolidColor color="haloBlue" alpha="0.2" />
    				</mx:verticalFill>
    				<mx:verticalAlternateFill>
    					<mx:SolidColor color="haloSilver" alpha="0.2" />
    				</mx:verticalAlternateFill>
    			</mx:GridLines>
    		</mx:backgroundElements>
    		<!-- vertical axis -->
    		<mx:verticalAxis>
    			<mx:LinearAxis id="chartVerticalAxis" displayName="Count" baseAtZero="false" title="Count" />
    		</mx:verticalAxis>
    		
    		<!-- horizontal axis -->
    		<mx:horizontalAxis>
    			<mx:CategoryAxis id="chartHorizontalAxis" categoryField="@datePoint" title="Date" />
    		</mx:horizontalAxis>
    		
    		<!-- horizontal axis renderer -->
    		<mx:horizontalAxisRenderers>
    			<mx:AxisRenderer axis="{chartHorizontalAxis}" canDropLabels="true" />
    		</mx:horizontalAxisRenderers>
    		
    		<!-- series -->
    		<mx:series>
    		</mx:series>
    	</mx:LineChart>
    	<!-- this is a http service used for send request and get return result do something-->
    	<mx:HTTPService id="httpServiceXMl" url="http://example.com//example params" method="POST" showBusyCursor="true" resultFormat="e4x">
    		<mx:request>
    			<method>public</method>
    			<type>xml</type>
    		</mx:request>
    	</mx:HTTPService>
    	<mx:Script>
    		<![CDATA[
    			import mx.charts.chartClasses.DataDescription;
    			import mx.charts.series.LineSeries;
    			import mx.collections.XMLListCollection;
    			import mx.controls.Alert;
    			import mx.events.CloseEvent;
    			import mx.rpc.events.FaultEvent;
    			import mx.rpc.events.ResultEvent;
    			import spark.components.CheckBox;
    			
    			// declare some global variable
    			var checkChanged:Boolean = false;			//用于标记事件的来源是否是由check box的改变而触发的, true为是,false为其他触发
    			var showModel:String = "Ind";				//用于标记当前选择的是 Individua, MultiInd Individua, 还是 ALL Individua
    			var groupBy:String = "byMonth";				//用于标记当前选择的是byHour,byDay,byWeek,byMonth,byYear
    			var previousDateFrom:String;				//用于在鼠标事件mousedown中记录dateFrom改变时间前的值
    			var previousDateTo:String;					//用于在鼠标事件mousedown中记录dateTo改变时间前的值
    			var showType:String = "";					//用于标记当前是哪儿check box触发的,PT或NC或....
    			var showTypeArray:Array = new Array;		//用于记录所有check box的selected为true的ID,ON,OE,ST,LJ或....
    			var basicUrl:String = "http://tools.localhost:8080";	//接受请求的服务器域名,命名规则为 "http://example.com"
    			
    			private function init():void
    			{
    				//init some checkbox' enable
    				//这些check box只有当ALL Individua 的selected为true时才能用
    				DCO.enabled = false; 
    				DE.enabled = false; 
    				JIL.enabled = false; 
    				CIL.enabled = false; 
    				TIL.enabled = false; 
    				FIL.enabled = false; 
    				CCL.enabled = false; 
    				NJL.enabled = false; 
    				NEL.enabled = false; 
    				LJ.enabled = false;
    				ST.enabled = false;		
    				//bind http service which used for get xml info and bind to userlist
    				httpServiceXMl.addEventListener(ResultEvent.RESULT,onResult);
    				httpServiceXMl.addEventListener(FaultEvent.FAULT,onFault);
    				httpServiceXMl.url = "http://tools.localhost:8080/emailtrace/flexconphp/init/lsds";
    				httpServiceXMl.send();
    				//init dateFrom and dateTo date
    				var dt:Date = new Date;
    				var df:Date = new Date;
    				df["date"] -= 7;	
    				dateFrom.text = df.fullYear.toString()+"-"+(df.getMonth().toString().length == 1 ? ("0"+(df.getMonth()+1)):(df.getMonth()+1))+"-"+(df.getDate().toString().length == 1?"0"+(df.getDate()):df.getDate());
    				dateTo.text = dt.fullYear.toString()+"-"+(dt.getMonth().toString().length == 1 ? ("0"+(dt.getMonth()+1)):(dt.getMonth()+1))+"-"+(dt.getDate().toString().length == 1?"0"+(dt.getDate()):dt.getDate());
    				//init checkbox enable to false, cuz it's have no data or don't sure
    				NCA.enabled = false;
    				SCV.enabled = false;
    				APP.enabled = false;
    				DCA.enabled = false;
    				NCJ.enabled = false;
    				DCJ.enabled = false;
    				OE.enabled = false;
    				HE.enabled = false;
    				HC.enabled = false;
    				//don't sure so init enable to false
    				byHour.enabled = false;			
    				/***************************************/
    				/************add event listener ********/
    				/***************************************/
    				userList.addEventListener(Event.CHANGE,userList_changeHandler);
    				dateFrom.addEventListener(Event.CHANGE,checkDateRight);
    				dateFrom.addEventListener(MouseEvent.MOUSE_DOWN,dateFrom_MouseDownHandler);
    				dateTo.addEventListener(Event.CHANGE,checkDateRight);
    				dateTo.addEventListener(MouseEvent.MOUSE_DOWN,dateTo_MouseDownHandler);
    				testDB.addEventListener(MouseEvent.CLICK,testBindDB);
    //				byHour.addEventListener(Event.CHANGE,byHour_changeHandler);
    				byDay.addEventListener(Event.CHANGE,byDay_changeHandler);
    				byWeek.addEventListener(Event.CHANGE,byWeek_changeHandler);
    				byMonth.addEventListener(Event.CHANGE,byMonth_changeHandler);
    				byYear.addEventListener(Event.CHANGE,byYear_changeHandler);
    				Ind.addEventListener(Event.CHANGE,Ind_changeHandler);
    //				MultiInd.addEventListener(Event.CHANGE,MultiInd_changeHandler);
    				AllInd.addEventListener(Event.CHANGE,AllInd_changeHandler);
    				
    				//bind change event to check box
    				/****************CANDIDATE********************/
    				NCO.addEventListener(Event.CHANGE,NCO_changeHandler);
    //				NCA.addEventListener(Event.CHANGE,NCA_changeHandler);
    //				APP.addEventListener(Event.CHANGE,APP_changeHandler);
    //				SCV.addEventListener(Event.CHANGE,SCV_changeHandler);
    //				DCA.addEventListener(Event.CHANGE,DCA_changeHandler);
    				DCO.addEventListener(Event.CHANGE,DCO_changeHandler);
    				/****************CLIENTS********************/
    //				NCJ.addEventListener(Event.CHANGE,NCJ_changeHandler);
    				SE.addEventListener(Event.CHANGE,SE_changeHandler);
    				TM.addEventListener(Event.CHANGE,TM_changeHandler);
    				FM.addEventListener(Event.CHANGE,FM_changeHandler);
    				NO.addEventListener(Event.CHANGE,NO_changeHandler);
    				NJ.addEventListener(Event.CHANGE,NJ_changeHandler);
    				NE.addEventListener(Event.CHANGE,NE_changeHandler);
    //				DCJ.addEventListener(Event.CHANGE,DCJ_changeHandler);
    				DE.addEventListener(Event.CHANGE,DE_changeHandler);
    				/****************SPEED********************/
    				JIL.addEventListener(Event.CHANGE,JIL_changeHandler);
    				CIL.addEventListener(Event.CHANGE,CIL_changeHandler);
    				TIL.addEventListener(Event.CHANGE,TIL_changeHandler);
    				FIL.addEventListener(Event.CHANGE,FIL_changeHandler);
    				CCL.addEventListener(Event.CHANGE,CCL_changeHandler);
    				NJL.addEventListener(Event.CHANGE,NJL_changeHandler);
    				NEL.addEventListener(Event.CHANGE,NEL_changeHandler);
    				/****************OTHERS********************/
    				AT.addEventListener(Event.CHANGE,AT_changeHandler);
    				OC.addEventListener(Event.CHANGE,OC_changeHandler);
    				PT.addEventListener(Event.CHANGE,PT_changeHandler);
    //				OE.addEventListener(Event.CHANGE,OE_changeHandler);
    				ON.addEventListener(Event.CHANGE,ON_changeHandler);
    				RE.addEventListener(Event.CHANGE,RE_changeHandler);
    				uOC.addEventListener(Event.CHANGE,uOC_changeHandler);
    				LJ.addEventListener(Event.CHANGE,LJ_changeHandler);
    				ST.addEventListener(Event.CHANGE,ST_changeHandler);
    //				HE.addEventListener(Event.CHANGE,HE_changeHandler);
    //				HC.addEventListener(Event.CHANGE,HC_changeHandler);
    				JI.addEventListener(Event.CHANGE,JI_changeHandler);
    				FI.addEventListener(Event.CHANGE,FI_changeHandler);
    				CC.addEventListener(Event.CHANGE,CC_changeHandler);
    				CI.addEventListener(Event.CHANGE,CI_changeHandler);
    				TI.addEventListener(Event.CHANGE,TI_changeHandler);
    
    			}
    			
    			protected function userList_changeHandler(event:Event):void
    			{
    				//如果check  box 有选中项,则当下拉框值改变后刷新坐标信息
    				if(showTypeArray.length > 0)
    					sendRequestAndGetXMlDrawLineOnChart();
    			}
    			
    			protected function checkDateRight(event:Event):void
    			{
    				//当dateFrom或dateTo改变时,检查时间是否合理,不合理则不允许修改,返回改变前的值;合理的就修改并且刷新图标坐标值
    				var dateFromArray:Array = dateFrom.text.split("-");
    				var dateFromDate:Date = new Date(dateFromArray[0],dateFromArray[1],dateFromArray[2]);
    				var dateToArray:Array = dateTo.text.split("-");
    				var dateToDate:Date = new Date(dateToArray[0],dateToArray[1],dateToArray[2]);
    				if(dateFromDate.time.valueOf() - dateToDate.time.valueOf() >= 0)
    				{
    					Alert.show("Error Date","ERROR",0);
    					if(event.target.id == "dateFrom")
    					{
    						dateFrom.text = previousDateFrom;
    					}
    					else
    					{
    						dateTo.text = previousDateTo;
    					}
    				}
    				if(showTypeArray.length > 0)
    					sendRequestAndGetXMlDrawLineOnChart();
    			}
    
    			protected function byHour_changeHandler(event:Event):void
    			{
    				//如果check  box 有选中项,则设定默认值,否则就刷新坐标信息
    				groupBy = "byHour";
    				if(showTypeArray.length == 0 )
    				{
    					var dt:Date = new Date;
    					var df:Date = new Date;			
    					df["hours"] -= 8;	
    					dateFrom.text = df.fullYear.toString()+"-"+(df.getMonth().toString().length == 1 ? ("0"+(df.getMonth()+1)):(df.getMonth()+1))+"-"+(df.getDate().toString().length == 1?"0"+(df.getDate()):df.getDate());
    					dateTo.text = dt.fullYear.toString()+"-"+(dt.getMonth().toString().length == 1 ? ("0"+(dt.getMonth()+1)):(dt.getMonth()+1))+"-"+(dt.getDate().toString().length == 1?"0"+(dt.getDate()):dt.getDate());
    				}
    				else
    					sendRequestAndGetXMlDrawLineOnChart();
    			}
    			protected function byDay_changeHandler(event:Event):void
    			{
    				groupBy = "byDay";
    				if(showTypeArray.length == 0)
    				{
    					var dt:Date = new Date;
    					var df:Date = new Date;
    					df["date"] -= 7;	
    					dateFrom.text = df.fullYear.toString()+"-"+(df.getMonth().toString().length == 1 ? ("0"+(df.getMonth()+1)):(df.getMonth()+1))+"-"+(df.getDate().toString().length == 1?"0"+(df.getDate()):df.getDate());
    					dateTo.text = dt.fullYear.toString()+"-"+(dt.getMonth().toString().length == 1 ? ("0"+(dt.getMonth()+1)):(dt.getMonth()+1))+"-"+(dt.getDate().toString().length == 1?"0"+(dt.getDate()):dt.getDate());
    				}
    				else
    					sendRequestAndGetXMlDrawLineOnChart();
    			}
    			protected function byWeek_changeHandler(event:Event):void
    			{
    				groupBy = "byWeek";
    				if(showTypeArray.length == 0)
    				{
    					var dt:Date = new Date;
    					var df:Date = new Date;
    					df["date"] -= 49;	
    					dateFrom.text = df.fullYear.toString()+"-"+(df.getMonth().toString().length == 1 ? ("0"+(df.getMonth()+1)):(df.getMonth()+1))+"-"+(df.getDate().toString().length == 1?"0"+(df.getDate()):df.getDate());
    					dateTo.text = dt.fullYear.toString()+"-"+(dt.getMonth().toString().length == 1 ? ("0"+(dt.getMonth()+1)):(dt.getMonth()+1))+"-"+(dt.getDate().toString().length == 1?"0"+(dt.getDate()):dt.getDate());
    				}
    				else
    					sendRequestAndGetXMlDrawLineOnChart();
    			}
    			protected function byMonth_changeHandler(event:Event):void
    			{
    				groupBy = "byMonth";
    				if(showTypeArray.length == 0)
    				{
    					var dt:Date = new Date;
    					var df:Date = new Date;
    					df["month"] -= 7;	
    					dateFrom.text = df.fullYear.toString()+"-"+(df.getMonth().toString().length == 1 ? ("0"+(df.getMonth()+1)):(df.getMonth()+1))+"-"+(df.getDate().toString().length == 1?"0"+(df.getDate()):df.getDate());
    					dateTo.text = dt.fullYear.toString()+"-"+(dt.getMonth().toString().length == 1 ? ("0"+(dt.getMonth()+1)):(dt.getMonth()+1))+"-"+(dt.getDate().toString().length == 1?"0"+(dt.getDate()):dt.getDate());
    				}
    				else
    					sendRequestAndGetXMlDrawLineOnChart();
    			}
    			protected function byYear_changeHandler(event:Event):void
    			{
    				groupBy = "byYear";
    				if(showTypeArray.length == 0)
    				{
    					var dt:Date = new Date;
    					var df:Date = new Date;
    					df["month"] -= 36;	
    					dateFrom.text = df.fullYear.toString()+"-"+(df.getMonth().toString().length == 1 ? ("0"+(df.getMonth()+1)):(df.getMonth()+1))+"-"+(df.getDate().toString().length == 1?"0"+(df.getDate()):df.getDate());
    					dateTo.text = dt.fullYear.toString()+"-"+(dt.getMonth().toString().length == 1 ? ("0"+(dt.getMonth()+1)):(dt.getMonth()+1))+"-"+(dt.getDate().toString().length == 1?"0"+(dt.getDate()):dt.getDate());
    				}
    				else
    					sendRequestAndGetXMlDrawLineOnChart();
    			}
    			
    			protected function dateFrom_MouseDownHandler(event:MouseEvent):void
    			{
    				//mouse down时记录dateFrom改变之前的日期
    				previousDateFrom = dateFrom.text;
    			}
    			
    			protected function dateTo_MouseDownHandler(event:MouseEvent):void
    			{
    				previousDateTo = dateTo.text;	
    			}
    			
    			protected function Ind_changeHandler(event:Event):void
    			{
    				//改变showModel为IND,清空图表的线条对象和dataprovider,屏蔽一些checkbox,设定所有checkbox的enabled为false
    				showModel = "Ind";
    				setAllCheckBoxSelectedExceptThis(false,"");
    				clearAllItemsInCharts();
    				DCO.enabled = false; 
    				DE.enabled = false; 
    				JIL.enabled = false; 
    				CIL.enabled = false; 
    				TIL.enabled = false; 
    				FIL.enabled = false; 
    				CCL.enabled = false; 
    				NJL.enabled = false; 
    				NEL.enabled = false; 
    				LJ.enabled = false;
    				ST.enabled = false;	
    			}
    
    			protected function MultiInd_changeHandler(event:Event):void
    			{
    				showModel = "MultiInd";
    				setAllCheckBoxSelectedExceptThis(false,"");
    				clearAllItemsInCharts();
    				DCO.enabled = false; 
    				DE.enabled = false; 
    				JIL.enabled = false; 
    				CIL.enabled = false; 
    				TIL.enabled = false; 
    				FIL.enabled = false; 
    				CCL.enabled = false; 
    				NJL.enabled = false; 
    				NEL.enabled = false; 
    				LJ.enabled = false;
    				ST.enabled = false;	
    			}
    
    			protected function AllInd_changeHandler(event:Event):void
    			{
    				showModel = "AllInd";
    				setAllCheckBoxSelectedExceptThis(false,"");
    				clearAllItemsInCharts();
    				DCO.enabled = true; 
    				DE.enabled = true; 
    				JIL.enabled = true; 
    				CIL.enabled = true; 
    				TIL.enabled = true; 
    				FIL.enabled = true; 
    				CCL.enabled = true; 
    				NJL.enabled = true; 
    				NEL.enabled = true; 
    				LJ.enabled = true;
    				ST.enabled = true;	
    			}
    			/****************CANDIDATE********************/
    			//CANDIDATE Check Box---NCO, 设定全局变量(标记是否有checkbox触发的)checkChanged为true,然后条用drawLine
    			protected function NCO_changeHandler(event:Event):void
    			{
    				showType = "NCO";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			
    			protected function NCA_changeHandler(event:Event):void
    			{
    				showType = "NCA";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function APP_changeHandler(event:Event):void
    			{
    				showType = "APP";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function SCV_changeHandler(event:Event):void
    			{
    				showType = "SCV";
    				drawLine(event, showType);
    			}
    			
    			protected function DCA_changeHandler(event:Event):void
    			{
    				showType = "DCA";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function DCO_changeHandler(event:Event):void
    			{
    				showType = "DCO";
    				drawLine(event, showType);
    			}
    			/****************CLIENTS********************/
    			//CLIENTS Check Box---NCJ, 设定全局变量(标记是否有checkbox触发的)checkChanged为true,然后条用drawLine
    			protected function NCJ_changeHandler(event:Event):void
    			{
    				showType = "NCJ";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function SE_changeHandler(event:Event):void
    			{
    				showType = "SE";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function TM_changeHandler(event:Event):void
    			{
    				showType = "TM";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function FM_changeHandler(event:Event):void
    			{
    				showType = "FM";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function NO_changeHandler(event:Event):void
    			{
    				showType = "NO";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function NJ_changeHandler(event:Event):void
    			{
    				showType = "NJ";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function NE_changeHandler(event:Event):void
    			{
    				showType = "NE";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function DCJ_changeHandler(event:Event):void
    			{
    				showType = "DCJ";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function DE_changeHandler(event:Event):void
    			{
    				showType = "DE";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			/****************SPEED********************/
    			//SPEED Check Box---JIL, 设定全局变量(标记是否有checkbox触发的)checkChanged为true,然后条用drawLine
    			protected function JIL_changeHandler(event:Event):void
    			{
    				showType = "JIL";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function CIL_changeHandler(event:Event):void
    			{
    				showType = "CIL";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function TIL_changeHandler(event:Event):void
    			{
    				showType = "TIL";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function FIL_changeHandler(event:Event):void
    			{
    				showType = "FIL";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function CCL_changeHandler(event:Event):void
    			{
    				showType = "CCL";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function NJL_changeHandler(event:Event):void
    			{
    				showType = "NJL";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function NEL_changeHandler(event:Event):void
    			{
    				showType = "NEL";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			/****************OTHERS********************/
    			//OTHERS Check Box---AT, 设定全局变量(标记是否有checkbox触发的)checkChanged为true,然后条用drawLine
    			protected function AT_changeHandler(event:Event):void
    			{
    				showType = "AT";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function OC_changeHandler(event:Event):void
    			{
    				showType = "OC";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function PT_changeHandler(event:Event):void
    			{
    				showType = "PT";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function OE_changeHandler(event:Event):void
    			{
    				showType = "OE";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function ON_changeHandler(event:Event):void
    			{
    				showType = "ON";
    				checkChanged = true;
    				drawLine(event, showType);
    			}	
    			
    			protected function RE_changeHandler(event:Event):void
    			{
    				showType = "RE";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function uOC_changeHandler(event:Event):void
    			{
    				showType = "UOC";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function LJ_changeHandler(event:Event):void
    			{
    				showType = "LJ";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function ST_changeHandler(event:Event):void
    			{
    				showType = "ST";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function HE_changeHandler(event:Event):void
    			{
    				showType = "HE";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function HC_changeHandler(event:Event):void
    			{
    				showType = "HC";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function JI_changeHandler(event:Event):void
    			{
    				showType = "JI";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    			
    			protected function FI_changeHandler(event:Event):void
    			{
    				showType = "FI";
    				checkChanged = true;
    				drawLine(event, showType);
    			}	
    			
    			protected function CC_changeHandler(event:Event):void
    			{
    				showType = "CC";
    				checkChanged = true;
    				drawLine(event, showType);
    			}	
    			
    			protected function CI_changeHandler(event:Event):void
    			{
    				showType = "CI";
    				checkChanged = true;
    				drawLine(event, showType);
    			}	
    			
    			protected function TI_changeHandler(event:Event):void
    			{
    				showType = "AT";
    				checkChanged = true;
    				drawLine(event, showType);
    			}
    		
    			/***********************************************/
    			/**************FUNCTIONS FOR EVENTS*************/
    			/***********************************************/
    			private function drawLine(event:Event, showType:String):void
    			{
    				//如果check box 选中,并且showModel是individual或者All individual的,则将showType加入选中数组,并在图表中添加一条线,并重新读取坐标信息,这个需要通信
    				//否则 从数组中取出当前check box对应的项,并从图表图标中去除对应的line serie对象,从linechart的dataprovider取出对应该项的属性值,此时不需要通信
    				if(event.target.selected == true && (showModel == "Ind" || showModel == "AllInd"))
    				{
    					pushShowTypeInArray(showType);
    					sendRequestAndGetXMlDrawLineOnChart();
    				}
    				else if(event.target.selected == false && (showModel == "Ind" || showModel == "AllInd"))
    				{
    					deleteXmlShowItem(showType);
    					popShowTypeInArray(showType);
    				}
    			}
    			
    			//做清理工作的函数
    			private function clearAllItemsInCharts():void
    			{
    				clearLineChartSeries();			
    				clearLineChartDataProvider();	
    				setAllCheckBoxSelectedExceptThis(false);
    			}
    			//去除linechart内部的line serie对象
    			private function clearLineChartSeries():void
    			{
    				var seriesArray:Array = new Array;
    				lineChart.series = seriesArray;
    			}
    			//去除linechart的数据绑定
    			private function clearLineChartDataProvider():void
    			{
    				lineChart.dataProvider = null;
    			}
    			//设定所有的项目为flase;
    			protected function setAllCheckBoxSelectedExceptThis(isSelected:Boolean,showOnly:String = ""):void
    			{				
    				showOnly == 'NCO'?NCO.selected = !isSelected:NCO.selected = isSelected;
    				showOnly == 'NCA'?NCA.selected = !isSelected:NCA.selected = isSelected;
    				showOnly == 'APP'?APP.selected = !isSelected:APP.selected = isSelected;
    				showOnly == 'SCV'?SCV.selected = !isSelected:SCV.selected = isSelected;
    				showOnly == 'DCA'?DCA.selected = !isSelected:DCA.selected = isSelected;
    				showOnly == 'DCO'?DCO.selected = !isSelected:DCO.selected = isSelected;
    				
    				showOnly == 'NCJ'?NCJ.selected = !isSelected:NCJ.selected = isSelected;
    				showOnly == 'SE'?SE.selected = !isSelected:SE.selected = isSelected;
    				showOnly == 'TM'?TM.selected = !isSelected:TM.selected = isSelected;
    				showOnly == 'FM'?FM.selected = !isSelected:FM.selected = isSelected;
    				showOnly == 'NO'?NO.selected = !isSelected:NO.selected = isSelected;
    				showOnly == 'NJ'?NJ.selected = !isSelected:NJ.selected = isSelected;
    				showOnly == 'NE'?NE.selected = !isSelected:NE.selected = isSelected;
    				showOnly == 'DCJ'?DCJ.selected = !isSelected:DCJ.selected = isSelected;
    				showOnly == 'DE'?DE.selected = !isSelected:DE.selected = isSelected;
    				
    				showOnly == 'JIL'?JIL.selected = !isSelected:JIL.selected = isSelected;
    				showOnly == 'CIL'?CIL.selected = !isSelected:CIL.selected = isSelected;
    				showOnly == 'TIL'?TIL.selected = !isSelected:TIL.selected = isSelected;
    				showOnly == 'FIL'?FIL.selected = !isSelected:FIL.selected = isSelected;
    				showOnly == 'CCL'?CCL.selected = !isSelected:CCL.selected = isSelected;
    				showOnly == 'NJL'?NJL.selected = !isSelected:NJL.selected = isSelected;
    				showOnly == 'NEL'?NEL.selected = !isSelected:NEL.selected = isSelected;
    				
    				showOnly == 'AT'?AT.selected = !isSelected:AT.selected = isSelected;
    				showOnly == 'OC'?OC.selected = !isSelected:OC.selected = isSelected;
    				showOnly == 'PT'?PT.selected = !isSelected:PT.selected = isSelected;
    				showOnly == 'OE'?OE.selected = !isSelected:OE.selected = isSelected;
    				showOnly == 'ON'?ON.selected = !isSelected:ON.selected = isSelected;
    				showOnly == 'RE'?RE.selected = !isSelected:RE.selected = isSelected;
    				showOnly == 'uOC'?uOC.selected = !isSelected:uOC.selected = isSelected;
    				showOnly == 'LJ'?LJ.selected = !isSelected:LJ.selected = isSelected;
    				showOnly == 'ST'?ST.selected = !isSelected:ST.selected = isSelected;
    				showOnly == 'HE'?HE.selected = !isSelected:HE.selected = isSelected;
    				showOnly == 'HC'?HC.selected = !isSelected:HC.selected = isSelected;
    				showOnly == 'JI'?JI.selected = !isSelected:JI.selected = isSelected;
    				showOnly == 'FI'?FI.selected = !isSelected:FI.selected = isSelected;
    				showOnly == 'CC'?CC.selected = !isSelected:CC.selected = isSelected;
    				showOnly == 'CI'?CI.selected = !isSelected:CI.selected = isSelected;
    				showOnly == 'TI'?TI.selected = !isSelected:TI.selected = isSelected;
    			}
    			//通过url,用http service发送请求,并用drawChartByResult处理返回的值
    			//request样例://http://tools.localhost:8080/emailtrace/flexconphp/from/2011-02-28/to/2011-03-07/groupby/byMonth/module/CC|PT|UOC/showModule/Ind/user/Fliex jin
    			private function sendRequestAndGetXMlDrawLineOnChart():void
    			{
    				httpServiceXMl.addEventListener(ResultEvent.RESULT,drawChartByResult);
    				httpServiceXMl.url = basicUrl + "/emailtrace/flexconphp/from/"+dateFrom.text+"/to/"+dateTo.text+"/groupby/"+groupBy+"/module/"+getShowTypeArrayByString()+"/showModule/"+showModel+"/user/"+userList.selectedLabel;
    				httpServiceXMl.send();
    			}
    			//用于记录选中的check box
    			private function pushShowTypeInArray(showType:String):void
    			{
    				var isFound:Boolean = false;
    				for(var i:int = 0; i < showTypeArray.length; i++)
    					if(showTypeArray[i].toString() == showType)
    						isFound = true;
    				if(isFound == false)
    					showTypeArray.push(showType);
    			}
    			//删除取消选中的check box
    			private function popShowTypeInArray(showType:String):void
    			{
    				var newArray:Array = new Array;
    				for(var i:int = 0; i < showTypeArray.length; i++)
    					if(showTypeArray[i].toString() != showType)
    						newArray.push(showTypeArray[i].toString());
    				showTypeArray = newArray;
    			}
    			//将选中的check box 通过字符串的方式返回   例如:PT|OC|JI|LJ
    			private function getShowTypeArrayByString():String
    			{
    				var showTypeStr:String = "";
    				for(var i:int = 0; i < showTypeArray.length; i++)
    					showTypeStr += "|"+showTypeArray[i].toString();
    				return showTypeStr.substr(1,showTypeStr.length);
    			}
    			
    			// http service 返回值处理,只有当check box触发的事件时,才有新的线条出现
    			private function drawChartByResult(event:ResultEvent):void 
    			{
    				//将返回的xml重新绑定在chart上
    				var userCollection:XMLListCollection = new XMLListCollection();
    				var tempXml:XML = event.result as XML;
    				var xmlList:XMLList = tempXml.elements("object");
    				userCollection.source = xmlList;
    				lineChart.dataProvider = userCollection;
    				//如果是check box触发的事件,则在图表中添加新的line serie对象
    				if(checkChanged == true)
    				{
    					var ONLineSerie:LineSeries = new LineSeries;;
    					var lineArray:Array = new Array();
    					ONLineSerie.id = showType + "_LineSerie";
    					lineArray = lineChart.series;
    					ONLineSerie.yField = "@"+showType+"_staticCount";//折线Y周起伏的依赖项
    					ONLineSerie.displayName = showType+" Count";//data tips内的title
    					chartVerticalAxis.title = "Count";			//y轴title
    					chartHorizontalAxis.title = "Date";		//x轴title
    					chartHorizontalAxis.categoryField = "@datePoint"; //x周显示的刻度依赖项
    					lineArray.push(ONLineSerie);
    					lineChart.series = lineArray;
    					checkChanged = false;
    				}
    			}
    			//service for http service, get xml from tools and bind to dropdownlist
    			private function onResult(event:ResultEvent):void 
    			{
    				var tempXml:XML = event.result as XML;
    				userList.dataProvider = tempXml.children();
    				httpServiceXMl.removeEventListener(ResultEvent.RESULT,onResult);
    			}
    			//service for http service, show error if can't get xml successfully
    			private function onFault(event:FaultEvent):void 
    			{
    				var resultXML:String = event.fault.toString();
    				Alert.show(resultXML);
    				
    			}
    			//从dataprovider中删除对应的属性,从lineChart的line series中删除对应的line serie对象
    			private function deleteXmlShowItem(showItem:String):void
    			{
    				var tempXMLListCollection:XMLListCollection = lineChart.dataProvider as XMLListCollection;
    				var tempXmlList:XMLList = tempXMLListCollection.source;
    				for(var i:int = 0; i < tempXmlList.length(); i++)
    					delete tempXmlList.@[showItem+"_staticCount"];
    				tempXMLListCollection.source = tempXmlList;
    				
    				var lineSeriesArray:Array = new Array;
    				for(var i:int = 0; i < lineChart.series.length; i++)
    					if(lineChart.series[i].id != showItem+"_LineSerie")
    						lineSeriesArray.push(lineChart.series[i]);
    				lineChart.series = lineSeriesArray;
    			}
    			
    			private function testBindDB(e:MouseEvent):void
    			{
    //				trace(lineChart.dataProvider.toString());
    //				for(var i:int = 0; i < lineChart.series.length; i++)
    //					trace(lineChart.series[i].id);
    				trace(showTypeArray.length);	
    //				var testXML:XML = <object datePoint="2011-03-08" AT_staticCount="0"/>;
    //				var tempXML:XML = <object datePoint="2011-03-08" AO_staticCount="55"/>;
    //				var dateFromArray:Array = testXML.attribute("datePoint").toString().split("-");
    //				var dateFromDate:Date = new Date(dateFromArray[0],dateFromArray[1],dateFromArray[2]);
    //				var dateToArray:Array = tempXML.attribute("datePoint").toString().split("-");
    //				var dateToDate:Date = new Date(dateToArray[0],dateToArray[1],dateToArray[2]);
    //				if(dateFromDate.time.valueOf() - dateToDate.time.valueOf() > 0)
    //				{
    //					Alert.show(">");
    //					Alert.show("Error Date","ERROR",0);
    //					var df:Date = new Date;
    //					df["date"] -= 7;	
    //					dateFrom.text = df.fullYear.toString()+"-"+(df.getMonth().toString().length == 1 ? ("0"+(df.getMonth()+1)):(df.getMonth()+1))+"-"+(df.getDate().toString().length == 1?"0"+(df.getDate()):df.getDate());
    //				}
    //				else if(dateFromDate.time.valueOf() - dateToDate.time.valueOf() < 0)
    //					Alert.show("<");
    //				else
    //				{
    ////					testXML.@["AO_staticCount"] = tempXML.attribute("AO_staticCount");
    //					delete testXML.@["AT_staticCount"];
    //				}
    //				Alert.show(testXML.toXMLString());
    				
    				
    				
    //				var tempXMLListCollection:XMLListCollection = lineChart.dataProvider as XMLListCollection;
    //				var tempXML:XMLList = tempXMLListCollection.source;
    //				var gotID:int = 0 ;
    //				for(var i:int =0; i < tempXML.length(); i++)
    //				{
    //					if(tempXML[i].attribute("datePoint") == "2011-02-24")
    //					{
    //						gotID = i;
    //						break;
    //					}
    //				}
    //				trace(tempXML);
    				
    				
    //				var tempXMl:XML = <object point="55" date="2010-4-6"/>;
    //				var tempStr:String = "sdsdsd";
    //				tempXMl.@[tempStr] = "sdsdksklfjgdlkfgdf"
    //				trace(tempXMl.toXMLString());
    				
    				
    				
    //				trace(tempXML[gotID].attribute("staticCount"));
    //				for(var i:int = 0; i < lineChart.series.length; i++)
    //					trace(lineChart.series[i].id.toString());
    				/*var chartSerieArray:Array = lineChart.series;
    				var tempChartSerieArray:Array = new Array;
    				for(var i:int = 0; i < chartSerieArray.length; i++)
    				{
    					if(chartSerieArray[i].id == "lineseriesEx")
    						tempChartSerieArray[tempChartSerieArray.length] = chartSerieArray[i];
    				}
    				lineChart.series = tempChartSerieArray;*/
    				
    				
    				
    //				trace(lineChart.series);
    //				lineChart.removeChild();
    				
    				//				lineChart.dataProvider = expenses;
    				//				lineseriesEx.yField = "Expenses"; //折线Y周起伏的依赖项
    				//				lineseriesEx.displayName = "Expenses";  //data tips内的title
    				//				chartVerticalAxis.title = "Acount";		//y轴title
    				//				chartHorizontalAxis.title = "Month";		//x轴title
    				//				chartHorizontalAxis.categoryField = "Month"; //x周显示的刻度依赖项
    			}
    		]]>
    	</mx:Script>
    		<mx:Style>         global         {                 dropShadowEnabled:false;         }     </mx:Style> 
    		<mx:Button x="235" y="491" label="test" id="testDB"/>
    		<mx:Canvas x="11" y="10" width="707" height="89">
    				<mx:DateField x="230" y="15" id="dateTo" monthNames='["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"]' formatString="YYYY-MM-DD" dayNames='["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]' yearNavigationEnabled="true" showToday="true"/>
    				<mx:DateField x="52" y="14" id="dateFrom" formatString="YYYY-MM-DD"/>
    				<mx:Label x="12" y="18" text="From" fontSize="15"/>
    				<mx:Label x="201" y="19" text="To" fontSize="15"/>
    				<mx:RadioButton x="67" y="49" label="day" id="byDay" groupName="GroupBy" selected="true"/>
    				<mx:RadioButton x="125" y="49" label="week" id="byWeek" groupName="GroupBy"/>
    				<mx:RadioButton x="189" y="49" label="month" id="byMonth" groupName="GroupBy"/>
    				<mx:RadioButton x="260" y="49" label="year" id="byYear" groupName="GroupBy"/>
    				<mx:RadioButton x="6" y="49" label="hour" id="byHour" groupName="GroupBy"/>
    				<mx:RadioButton x="388" y="10" groupName="showModel" label="Individual" id="Ind" selected="true"/>
    				<mx:RadioButton x="388" y="36" label="Multiple Individuals" groupName="showModel" id="MultiInd"/>
    				<mx:RadioButton x="388" y="62" label="All Individuals" groupName="showModel" id="AllInd" />
    				<mx:CheckBox x="566" y="36" label="Sum" id="isGetSum" />
    				<mx:ComboBox x="517" y="11" editable="false" id="userList" labelField="@label"></mx:ComboBox>
    		</mx:Canvas>
    		<mx:Panel x="480" y="116" width="136" height="122" layout="absolute" title="CANDIDATES">
    				<mx:CheckBox x="10" y="37" label="NCO" id="NCO" />
    				<mx:CheckBox x="84" y="37" label="NCA" id="NCA" />
    				<mx:CheckBox x="84" y="64" label="APP" id="APP" />
    				<mx:CheckBox x="10" y="64" label="SCV" id="SCV" />
    				<mx:CheckBox x="84" y="91" label="DCA" id="DCA" />
    				<mx:CheckBox x="10" y="91" label="DCO" id="DCO" />
    		</mx:Panel>
    		<mx:Panel x="480" y="248" width="136" height="175" layout="absolute" title="CLIENTS">
    				<mx:CheckBox x="10" y="36" label="NCJ" id="NCJ" />
    				<mx:CheckBox x="10" y="63" label="SE" id="SE" />
    				<mx:CheckBox x="83" y="63" label="TM" id="TM" />
    				<mx:CheckBox x="10" y="90" label="FM" id="FM" />
    				<mx:CheckBox x="83" y="90" label="NO" id="NO" />
    				<mx:CheckBox x="10" y="117" label="NJ" id="NJ" />
    				<mx:CheckBox x="83" y="117" label="NE" id="NE" />
    				<mx:CheckBox x="83" y="36" label="DCJ" id="DCJ" />
    				<mx:CheckBox x="10" y="144" label="DE" id="DE" />
    		</mx:Panel>
    		<mx:Panel x="480" y="433" width="136" height="146" layout="absolute" title="SPEED">
    				<mx:CheckBox x="10" y="36" label="JIL" id="JIL"/>
    				<mx:CheckBox x="83" y="36" label="CIL" id="CIL" />
    				<mx:CheckBox x="10" y="63" label="TIL" id="TIL" />
    				<mx:CheckBox x="83" y="63" label="FIL" id="FIL" />
    				<mx:CheckBox x="10" y="90" label="CCL" id="CCL" />
    				<mx:CheckBox x="82" y="90" label="NJL" id="NJL" />
    				<mx:CheckBox x="10" y="117" label="NEL" id="NEL" />
    		</mx:Panel>
    		<mx:Panel x="624" y="116" width="87" height="463" layout="absolute" title="OTHERS">
    				<mx:CheckBox x="10" y="36" label="AT" id="AT" />
    				<mx:CheckBox x="10" y="62" label="OC" id="OC" />
    				<mx:CheckBox x="10" y="114" label="PT" id="PT" />
    				<mx:CheckBox x="10" y="140" label="OE" id="OE" />
    				<mx:CheckBox x="10" y="166" label="ON" id="ON" />
    				<mx:CheckBox x="10" y="274" label="RE" id="RE" />
    				<mx:CheckBox x="10" y="88" label="uOC" id="uOC"/>
    				<mx:CheckBox x="10" y="409" label="LJ" id="LJ" />
    				<mx:CheckBox x="10" y="436" label="ST" id="ST" />
    				<mx:CheckBox x="10" y="193" label="HE" id="HE" />
    				<mx:CheckBox x="10" y="220" label="HC" id="HC" />
    				<mx:CheckBox x="10" y="247" label="JI" id="JI" />
    				<mx:CheckBox x="10" y="355" label="FI" id="FI" />
    				<mx:CheckBox x="10" y="382" label="CC" id="CC" />
    				<mx:CheckBox x="10" y="301" label="CI" id="CI" />
    				<mx:CheckBox x="10" y="328" label="TI" id="TI" />
    		</mx:Panel>
    </mx:Application>
    

  • 相关阅读:
    MySQL-MMM方案
    MySQL双主复制
    MySQL主从复制
    Keepalived实现高可用
    CentOS7.2 部署Haproxy 1.7.2
    博客园写随笔时用数学公式
    Java中有三种移位运算符
    VS Code配置C/C++环境
    Visual Studio Code 如何编写运行 C、C++ 程序?
    头一次知道“原地算法”?!
  • 原文地址:https://www.cnblogs.com/zcy_soft/p/1981401.html
Copyright © 2011-2022 走看看