Database structure:
Step one: Build the database. The example uses an Access database, with a table named Tblstaff, with three fields: Strid (AutoNumber), Strknownas (text), Strsurname (text). This is a database to demonstrate the user name, just add some data.
Step two: Create a flash 4 animation:
The steps are as follows:
1 Create three text field, which is used to display the data.
2 sets the name of the first text field to input, which is used to receive input data.
3 The other two text field is named Knownas and surname respectively.
4 other settings first for default.
5 Finally, select Add a button from the Flash library (should be a reusable component Scrollbarbutton). This is a very important step, the button will pass the input variables to the ASP page to the button's properties on the Click Action page, click the + and on MouseEvent, check the release box.
6 Click "+" and Load/unload Movie again, select "Load Variables into Location", enter your ASP filename (for example, flash.asp) in the URL input box, select Target.
7 Finally, select the Send using POST in Variables and click the "+" sign to set the variable. Enter "Input" in the Variable input box (the name of the first text field) when the above work is done, you should see the following in Action box:
On (release)
Load Variables ("flash.asp", "" ", Vars=post)
Set Variable: "Input" = ""
End on
This way, when the button is clicked and released during the animation, the contents of the input box are passed to the flash.asp file. Note that the form is a post way to pass variables.
8 now create an HTML page in which to include this Flash animation file.
Step three: Code for ASP files
<% Set Connection = Server.CreateObject ("ADODB.") Connection ")
Set Recordset = Server.CreateObject ("ADODB.") Recordset ")
Connection.Open "People" ' Your database-connected DSN
SQL = "SELECT * from Tblstaff WHERE strid=" & Request.Form ("Input") &
";"
Recordset.Open sql,connection,1,2
If recordset.eof Then
Knownas = "not"
Surname = "Found"
Else
Knownas = Recordset ("Strknownas")
Surname = Recordset ("Strsurname")
End If Recordset.close
Connection.close
Response.Write ("knownas=" +server.urlencode (Knownas)) Response.Write ("&surname=" +server.urlencode (Surname))
%>
Note that the Knownas and Surname are passed back to the writing, will be like this: Knownas=data1&surname=data2 use Server.URLEncode (VariableName) To ensure that passing variables are encoded in the URL format.
The following is a brief introduction to the principles of ASP and Flash communication:
Variables are actually passed to flash through the URL, in fact, this is a GET method, you do not use ASP can also pass variables to a SWF file, as long as:
< PARAM name=movie value= "Mymovie.swf?myvariable=text+of+my+variable" >
Then the text "text of my Variable" will appear in the Flash animation in the location specified, and then take advantage of Flash animation features can make a strong web page out. The simplest is to use flash to combine the database to draw a very beautiful pie chart.