System. usecodepage = true;
VaR myname: String = "";
VaR Telephone: String = "";
VaR mail: String = "";
VaR company: String = "";
VaR message: String = "";
VaR variables: urlvariables = new urlvariables (); // variables can be transmitted between flash applications and servers using the urlvariables class.
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; // specify the URLRequest object as post.
Loader. dataformat = urlloaderdataformat. text;
Loader. Load (myrequest); // send data
}
This is a field table: the database is MSG. MDB
:
Code for 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:
<%
Dim Conn
Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("MSG. mdb ")
%>
Code as shown above: only a few items are added on the basis of the original, and several fields are added to the database.
The code is not very parsed. Here is the help document: This flash.net package class is important.
If you do not understand, you can see that as3.0 communicates with ASP.
|
|
Urlloader
|
The urlloader class downloads data from a URL in the form of text, binary data, or URL-encoded variables.
|
|
|
Urlloaderdataformat
|
The urlloaderdataformat class provides values used to specify how to receive downloaded data.
|
|
|
URLRequest
|
The URLRequest class can capture all information in a single HTTP request.
|
|
|
Urlrequestheader
|
The urlrequestheader object encapsulates an HTTP request header and consists of a name/value pair.
|
|
|
Urlrequestmethod
|
The urlrequestmethod class provides values that specify whether the URLRequest object uses the post or get method when data is sent to the server.
|
|
|
Urlvariables
|
You can use the urlvariables class to transmit variables between flash applications and servers.
|