Flash (as3) connects to the database through Asp.net, and as3 connects to the database

Source: Internet
Author: User

Here we will talk about how Flash (as3) connects to the database through Asp.net, hoping to help some children's shoes.

 

Let's talk about the logic first, and then paste itCode:

As3 cannot directly operate databases. It can only operate data in one background language, such as C # And java. Here we will talk about as3's simple logic of calling Asp.net to operate databases, that is, as3 initiates a request, uses Asp.net to accept the corresponding parameters, uses Asp.net to operate the database, and then returnsProgramProgram.

 

As3: Use get to send data (external files ):

 
Package {public class main extends sprite {// declare a loader private var Loader: urlloader = new urlloader (); public function main (): void {// load page loader. load (New URLRequest ("http: // localhost: 8033/as3test. aspx? Message = 1 "); // listen to the multiload event loader. addeventlistener (event. complete, XX);} public function XX (ASD: Event): void {trace (loader. data );}}}

As3: Use post to send data (external files ):

Package {public class main extends sprite {// declare a loaderprivate var Loader: urlloader = new urlloader (); public function main (): void {// declare a URLRequest variable var url: URLRequest = new URLRequest ("http: // localhost: 8033/as3test. aspx "); // set the transmission mode to posturl. method = urlrequestmethod. post; // declare a urlvariablesvar values: urlvariables = new urlvariables (); // set the information values to be transmitted. message = "Flash"; URL. data = values; // you can specify a variable-value pair to parse the Data Loader. dataformat = urlloaderdataformat. variables; // load the page loader. load (URL); // listen to the multiload event loader. addeventlistener (event. complete, XX);} public function XX (ASD: Event): void {trace (loader. data );}}
}

In ASP. net, here only write some of the simplest code, directly receive the value and return it. As for the real operation of the database, I believe everyone knows how to operate, the method used to obtain the value is the request method. I encapsulate it here. You can write it yourself.

Protected void page_load (Object sender, eventargs e) {// string DDD = ak. T. pagerequest. getformstring ("message ");
String DDD = ak. T. pagerequest. getquerystring ("message"); response. Write ("ASPnet =" + DDD );}

Reprinted please indicate the source ------------ AK: 2012-07-24
Related Article

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.