【百行代码话应用】flex WebService应用之QQ在线客服实现

1.应用了flex中的webservice 组件,来调用QQ在线监测的接口  qqwebService.qqCheckOnline(qq_id.text);    qq_id.text 为输入的QQ号码

返回“Y” 表示在线,“N”表示离线

2.调用QQ在线聊天的借口,用来激发聊天框navigateToURL(new URLRequest("http://wpa.qq.com/msgrd?v=3&uin="+int(qq_id.text)+"&site=qq&menu=yes"),"_blank");

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
	<fx:Declarations>
		
		<mx:WebService id="qqwebService" wsdl="http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl"
					   showBusyCursor="true" result="onLoad2(event)" fault="faultHandler2(event)"/>
	</fx:Declarations>
	<fx:Script> 
		<![CDATA[ 
			import mx.collections.ArrayCollection;
			import mx.controls.Alert;
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			import mx.utils.ArrayUtil;
			
			private function onLoad2(event:ResultEvent):void{
				
				var code:String = event.result as String;
				if(code=="Y"){
					
					png_id.source="png/qq在线.jpg";
				}else{
					png_id.source="png/qq离线.jpg";
				}
				
				
			}
			//错误处理程序
			private function faultHandler2(event:FaultEvent):void{
				Alert.show(event.fault.toString(),'WebService Error');
				
			}
			
			private function send():void{
				if(qq_id.text==""||qq_id.text==null){
					Alert.show('请输入qq号码');
				}else{
					qqwebService.qqCheckOnline(qq_id.text);
				}
				
			}
			
			protected function image1_mouseDownHandler(event:MouseEvent):void 
			{ 
				navigateToURL(new URLRequest("http://wpa.qq.com/msgrd?v=3&uin="+int(qq_id.text)+"&site=qq&menu=yes"),"_blank"); 
			}
		]]> 
	</fx:Script> 
	<mx:VBox  width="100%" height="100%"  >
	<!--	<local:WeatherView  width="100%" height="100%"/>-->
		<mx:TextInput id="qq_id" text=""/>
		<mx:Button id="btn_send" click="send()"  label="检测"/>
		<mx:Image source="png/qq离线.jpg"  id="png_id" toolTip="在线客服"  mouseDown="image1_mouseDownHandler(event)"/> 
	</mx:VBox>
</s:Application>


 

【百行代码话应用】flex WebService应用之QQ在线客服实现_第1张图片

你可能感兴趣的:(【百行代码话应用】flex WebService应用之QQ在线客服实现)