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