Learn about flash (12) as3.0 and ASP communication every day (2)

Source: Internet
Author: User

 

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.