flex连asp

package asp
{
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLVariables;
	import flash.net.sendToURL;
	[Bindable]
	public class LoaderAsp
	{
		public var xml:XML;
		public function LoaderAsp()
		{
			getXML();
		}
		private function init():void{
			var url:URLRequest=new URLRequest("http://localhost/flex.asp");
			var data:URLVariables=new URLVariables;
			data.str="hello";
			url.data=data;
			flash.net.sendToURL(url);
			//flash.net.navigateToURL(url,"_self");
		}
		public function getXML():void{
			var urlLoader:URLLoader=new URLLoader();
			urlLoader.load(new URLRequest("http://localhost/getxml.asp"));
			urlLoader.addEventListener(Event.COMPLETE,onCom);
		}
		private function onCom(event:Event):void{
			var url:URLLoader=event.target as URLLoader;
			this.xml=XML(url.data);
		}
		

	}
}

  getxml.asp

<%
	response.write "<s><name>kangkangss</name><name>valuesss</name></s>"
	
%>

  flex.asp

<!--#include file="conn.asp"-->
<%
	
		
		
		sql="select * from rczp"
	 set rs=server.createobject("adodb.recordset")
	 response.write rs
	 rs.open sql,conn,1,3
	 rs.addnew
		
		
		rs("title")="fanyongkangs1"
		rs("content")="fanyongkangs1"
		
	  rs.update
	  rs.close
	  response.write "insert into"
	  response.write "hellosss"
		str=request.querystring("str")
		response.write str
%>

  app.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import asp.LoaderAsp;
			[Bindable]
			private var loadasp:LoaderAsp=new LoaderAsp;
			private function init():void{
				loadasp.getXML();
				this.http.send();
			}
		]]>
	</mx:Script>
	<mx:XML id="xmlList">
		<kangkang>
			<test>
				sadfsadf
			</test>
			<test>
				sadfsadf
			</test>
		</kangkang>
	</mx:XML>
	<mx:List dataProvider="{this.xmlList}" labelField="test">
		
	</mx:List>
	<mx:List dataProvider="{this.loadasp.xml}" labelField="..name">
		
	</mx:List>
	
	<mx:HTTPService id="http"
		 url="http://localhost/getxml.asp" 
		 resultFormat="xml">
		<mx:fault>
			<![CDATA[
				mx.controls.Alert.show("fault"+event.message);
				
			]]>
		</mx:fault>
		<mx:result>
			<![CDATA[
				mx.controls.Alert.show("result"+event.result);
			]]>
		</mx:result>
	</mx:HTTPService>
	<mx:List dataProvider="{this.http.lastResult}">
		
	</mx:List>
	<mx:Button>
		<mx:click>
			<![CDATA[
				init();
			]]>
		</mx:click>
	</mx:Button>
</mx:Application>
 

你可能感兴趣的:(xml,Flex,Flash,asp.net,asp)