Copy Code code as follows:
Can I pass variables to the ASP in Flash animation?
faq-it.org/vb/---------------------------------------------------------------
Database structure:
The first step is to build a database. Use an Access database in the example, with the table named Tblstaff
There are three fields: Strid (AutoNumber), Strknownas (text), Strsurname (text).
This is a database used to demonstrate the user name, just add some data.
The second step is to create a Flash 4 animation Rom:
The steps are as follows:
1) To create three text field. They're used to display data.
2 sets the name of the first text field to input, which is used to receive the input data
3 The other two text field is named Knownas and surname respectively.
4 Other settings first for the 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
Click the Action page on the button's properties. Click the + sign and on MouseEvent. Check the release box.
6 Click the "+" number 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. 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 that contains 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 way in which Knownas and surname are passed back is 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 through the URL to flash, which is actually a GET method
You can actually pass a variable to a SWF file without using ASP, 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
Okay, all right, now for the ASP developer, just get the data that Flash needs ready, and then take advantage of the animations in Flash
function can make a strong web page out. The simplest is to use the Flash database to draw a very beautiful pie chart, hehe. Anyway, as long as we can imagine, we can make
A lot of good stuff comes out.