Environment: adobe flash CS4, VS2008, Access2003
Steps:
1. Create the ASP.net page testCommunicateWithFlash. aspx, delete the content in the page body, and write code in the background to retrieve the database and generate similar content, for example:
Xqdbnum = 15 & xqdbfcnum = 5 & xqdbjrnum = 5 & xqdbxdnum = 5 & xqdbrzj = 1250000 & xqdbzrnum = 2
The content in flash will be parsed into six variables, with the variable name in front and value in the back. In other words, the code is very simple and everyone can understand it. Extract A passed parameter, extract the corresponding content, generate the upload above, and output it to the browser:
Copy codeThe Code is as follows: protected void Page_Load (object sender, EventArgs e)
{
Object oID; // user ID
If (! Page. IsPostBack)
{
Try
{
OID = Request. Params ["ID"];
}
Catch (Exception ex)
{
Response. Write (ex. Message );
Return;
}
OleDbConnection conn = new OleDbConnection ();
Conn. ConnectionString = "Provider = Microsoft. Jet. OLEDB.4.0; Persist Security Info = True; Data Source =" + Server. MapPath ("~ /App_Data/tdb_db.mdb ");
Conn. Open ();
OleDbCommand cmd = new OleDbCommand ();
Cmd. Connection = conn;
// Execute a specific SQL statement
Cmd. commandText = "SELECT sum (xqdbnum), sum (xqdbfcnum), sum (xqdbjrnum), sum (xqdbxdnum), sum (xqdbrzj), sum (xqdbzrnum) FROM xqdb where xqusername like '"+ oID. toString () + "% '";
OleDbDataReader reader = cmd. ExecuteReader ();
While (reader. Read ())
{
Response. write ("xqdbnum =" + reader. getValue (0) + "& xqdbfcnum =" + reader. getValue (1) + "& xqdbjrnum =" + reader. getValue (2) + "& xqdbxdnum =" + reader. getValue (3) + "& xqdbrzj =" + reader. getValue (4) + "& xqdbzrnum =" + reader. getValue (5);} reader. close ();
Conn. Close ();
}
}
2. Create a flash. I think the method on the Internet requires several frames, one for sending, one for waiting for return, and the other for display. Because I test all the display, it is not so complicated. I only need to monitor the variables of dynamic text, so I only have one frame, and the name is random, however, the variable settings of dynamic text are the same as those of the returned content (this is very important)
3. Create a button
4. write code in the button action:
On (release ){
Trace ("http://www.jb51.net: 1475/WebTest/TestCommunicateWithFlash. aspx? ID = "+ it_uid.text );
LoadVariables ("http://www.jb51.net: 1475/WebTest/TestCommunicateWithFlash. aspx? ID = "+ it_uid.text, this," POST ");
}
5. The test is successful.
6. If you publish a statement, you need to change the website address.
It involves some details. You can check the relevant information on the Internet and check it. It has never been done before. It took more than two hours to complete the process.