每天學一點flash(12) as3.0與asp通訊 (2)

來源:互聯網
上載者:User

 

 

System.useCodePage=true;

var myname:String="";

var telephone:String="";

var mail:String="";

var company:String ="";

var  message:String="";

 

var variables:URLVariables=new URLVariables();//使用 URLVariables 類可以在 Flash 應用程式和伺服器之間傳輸變數。

var myrequest:URLRequest=new URLRequest("http://localhost/save.asp");

var loader:URLLoader = new URLLoader();

 

mybutton.addEventListener(MouseEvent.CLICK,onclik);

function onclik(e:Event)

{

 

variables.myname=myname1.text;

variables.telephone=telephone1.text;

variables.mail=mail1.text;

variables.company=company1.text;

variables.message=message1.text;

 

 

myrequest.data=variables;

myrequest.method=URLRequestMethod.POST;//指定 URLRequest 對象為 POST。

loader.dataFormat = URLLoaderDataFormat.TEXT;

loader.load(myrequest);//發送資料

 

}

      

這個是欄位表:資料庫為Msg.mdb

:

sava.asp的代碼:

<!-- #include file=conn.asp -->
<%
if request("myname")="" then
response.Write("no data")
response.End()
else

u_name=Request("myname")
u_telephone=Request("telephone")
u_mail=Request("mail")
u_company=Request("company")

u_msg=Request("message")

sql="Insert into data (Name,Telephone,Mail,Company,Msg) values ('"&u_name&"','"&u_telephone&"','"&u_mail&"','"&u_company&"','"&u_msg&"')"
conn.Execute(sql)
conn.close
Set conn=Nothing
Response.Write "ok"
end if
%>

conn.asp串連access資料庫的檔案:

<%
 Dim conn
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & server.mappath("Msg.mdb")

%>

 

代碼如上面:只是在原來的基礎上增加了幾項 ,資料庫也增加了幾個欄位。

代碼不怎麼解析了,這裡提供協助文檔:其中這個flash.net這個包類是重要一點。

不明白的可以看as3.0與asp通訊

 

 

 

URLLoader

URLLoader 類以文本、位元據或 URL 編碼變數的形式從 URL 下載資料。

 

URLLoaderDataFormat

URLLoaderDataFormat 類提供了一些用於指定如何接收已下載資料的值。

 

URLRequest

URLRequest 類可捕獲單個 HTTP 要求中的所有資訊。

 

URLRequestHeader

URLRequestHeader 對象封裝了一個 HTTP 要求標題並由一個成對的名稱和數值組成。

 

URLRequestMethod

URLRequestMethod 類提供了一些值,這些值可指定在將資料發送到伺服器時,URLRequest 對象應使用 POST 方法還是 GET 方法。

 

URLVariables

使用 URLVariables 類可以在 Flash 應用程式和伺服器之間傳輸變數。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.