URLLoader的使用

<mx:Script>
	<![CDATA[
		import com.cjm.common.StringUtil;
		
		private var _urlLoader:URLLoader;
		
		private function completeHandler(event:Event):void{
			txt1.text = StringUtil.trim(_urlLoader.data);
		}
		
		private function errorHandler(event:IOErrorEvent):void{
			txt1.text = event.text;
		}
		
		private function init():void{
			_urlLoader = new URLLoader();
			_urlLoader.addEventListener(Event.COMPLETE, completeHandler);
			_urlLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
		}
		
		private function loadData():void{
			//URL请求
			var _url:String = "../test.jsp";
			var _urlRequest:URLRequest = new URLRequest(_url);
			
			//请求附带的参数值
			var _params:URLVariables = new URLVariables();
			_params.username = "cjm";
			_params.password = "pwd";
			_urlRequest.data = _params;
			_urlRequest.method = URLRequestMethod.POST;
			
			//装载请求数据
			_urlLoader.load(_urlRequest);
		}
	]]>
</mx:Script>

 

你可能感兴趣的:(jsp)