1,//抽象地址
[Event(name="sendUrl",type="flash.events.TextEvent")]
private function send():void
{
var event:TextEvent=new TextEvent("sendUrl");
event.text=url();
dispatchEvent(event);
}
private function url():String
{
var ip:String = "192.168.2.198";
var port:String = "8080";
var project:String = "cti";
var httpAddress:String = "http://" +
ip + ":" + port + "/" + project +
"/";
return httpAddress;
}
]]>
2,//发送数据
import mx.controls.Alert;
import flash.net.URLVariables;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
private var url:String=null;
[Inspectable]
[Bindable]
public var httpService_ID:HTTPService;
public var httpService_Url:String;
public var httpService_param:String;
private function getUrl(event:TextEvent):void
{
url=event.text;
Alert.show(url);
}
private function httpEncoding(param:String):String
{
return encodeURIComponent(param);
}
public function initHttp(httpid:HTTPService,serurl:String,params1:String):void //加载 菜单
{
//serurl="外部参数";
//params=""+params1+"
";
// httpid.url = serurl;
httpid.url=url+ serurl;//"sut/StatusReasonCategoryByTypeCode";
var params:URLVariables = new URLVariables();
params.ctixml=httpEncoding(params1);
//params.ctixml=params1;
httpid.send(params); //发送请求
Alert.show();
}
]]>
3,
4,
如果发送数据量过大的话,在3中要加入......:method="post"
用類操作:
package myas.http
{
import flash.net.URLVariables;
import com.protel.cti.util.CTIlog;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.HTTPService;
public class Init_http
{
public function Init_http()
{
}
private function httpEncoding(param:String):String//防止乱码
{
return encodeURIComponent(param);
}
public function initHttp(httpid:HTTPService,serurl:String,params1:String,Url:String):void //加载 菜单
{
httpid.url =Url+ serurl;//"sut/StatusReasonCategoryByTypeCode";
var params:URLVariables = new URLVariables();
params.ctixml=httpEncoding(params1);
httpid.send(params); //发送请求
}
/* import com.protel.cti.ctiSharedObject.CTISharedObjectManager;
private function initComplete():void
{
var loader:URLLoader = new URLLoader();
var request:URLRequest= new URLRequest("../FlexUrl.properties");
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);
}
private var urlString:String;
private function onComplete(event:Event):String
{
var loader:URLLoader = event.target as URLLoader;
urlString = loader.data;
urlString = urlString.substr(urlString.indexOf("=")+1);
return urlString;
// CTIlog.log(urlStiring);
}*/
public function initHttp_null(httpid:HTTPService,serurl:String,params1:String):void //加载 菜单
{
//serurl="外部参数";
//params="
"+params1+"
";
// httpid.url = serurl;
httpid.url = ServletUrl.getUrl_jason() + serurl;//"sut/StatusReasonCategoryByTypeCode";
var params:URLVariables = new URLVariables();
params.ctixml=httpEncoding(params1);//
httpid.send(params); //发送请求
}
public function initHttp_alex(httpid:HTTPService,serurl:String,params1:String):void //加载 菜单
{
//serurl="外部参数";
//params="
"+params1+"
";
// httpid.url = serurl;
httpid.url = ServletUrl.getUrl_alex() + serurl;//"sut/StatusReasonCategoryByTypeCode";
var params:URLVariables = new URLVariables();
params.ctixml=httpEncoding(params1);//
httpid.send(params); //发送请求
}
public function getResult(event:ResultEvent,httpId:HTTPService):XMLList
{
var xml_list:XMLList;
var s:String = httpId.lastResult.toString();
xml_list= new XMLList(s);
//CTIlog.log(xml_list);
return xml_list;
}
public function getResult_xml(event:ResultEvent,httpId:HTTPService):XML
{
var xml_list:XML;
var s:String = httpId.lastResult.toString();
xml_list= new XML(s);
//CTIlog.log(xml_list);
return xml_list;
}
public function getFault(event:FaultEvent):void
{
CTIlog.log("Error " + event.fault.message);
}
}
}
2:
private var myHttp:Init_http=new Init_http();
private var urlString:String=CTISharedObjectManager.getData("servleturl");
private var serve_url_up:String="CADVVerificationCondition.do?servlet=getAll&random="+UIDUtil.createUID();
private var par_up:String="
1";
private function getTaskListGet(event:ResultEvent):void
{
}
private function getTaskListSend(event:ResultEvent):void
{
}
private function getFault(event:FaultEvent):void
{
}
myHttp.initHttp(taskList_get,serurl_send,par_send,urlString)
用as实现顺序线程:
var testChangeIndle_http:HTTPService=new HTTPService;
testChangeIndle_http.resultFormat="text";
var idleper_url:String="AvailableAgent.do?random="+UIDUtil.createUID();
testChangeIndle_http.url =urlString + idleper_url;
var params:URLVariables = new URLVariables();
params.ctixml=par_idleper;
testChangeIndle_http.addEventListener(ResultEvent.RESULT,getTestIndlPeopleResult);
testChangeIndle_http.send(params);
function getTestIndlPeopleResult(event:ResultEvent):void
{
var s:String=testChangeIndle_http.lastResult.toString();
var xmlList:XMLList=new XMLList(s);
}