📄 readme.txt
字号:
FLASH QUERY
Author: Rafay Bin Ali
email: rafayali@gmail.com
URL: http://rafayali.blogspot.com
http://cyberdev.visit.ws
BASICS:
FLASH cannot access a database on its own. However, it can access it using some
scripting language such as ASP. The basic idea is that variables between ASP
and FLASH can be exchanged using QUERYSTRINGS.
FLASH GUIDE:
FLASH movie has 1 input textfield, 1 button in the green panel and 3 dynamic textfields in the black panel. The textfield in the green panel is where you would enter the name of the person to search. The code behind the button is as follows:
on (release) {
loadVariablesNum("data.asp?Record=" add myrecord, 0);
myrecord="";
firstName="";
lastName="";
City="";
errorMsg="Please wait";
}
The above code accesses the ASP file and retrieves whatever values are found in the
querystring.
ASP GUIDE:
The ASP code is given below:
<%
'This is the querystring value that was passed from your movie. It is retrieved by ASP
record=request("Record")
'Connection is made to the database by ASP
Set objconn=server.createobject("adodb.connection")
'Drive for database is loaded
objconn.open "provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("names.mdb")
'Recorset object is created. This is where the found record would be placed
set objrecord=server.createobject("adodb.recordset")
'The SELECT query is executed. It uses the querystring value that you had stored in a
'local variable in the first line of ASP code
set objrecord=objconn.execute("select * from mydbdata where firstName like'" & record & "'")
'if the record does not exist, send back an error value in the querystring.
if objrecord.eof or objrecord.bof then
Response.Write "errorMsg=Not Found&firstName=&lastName=&City="
response.end
else
'if the record does exist, send back the data in the querystring
Response.Write "errorMsg=Found&firstName=" & server.URLEncode(objrecord.fields("firstName")) & "&" & _
"lastName=" & server.URLEncode(objrecord.fields("lastName")) & "&" & _
"City=" & server.urlencode(objrecord.fields("City"))
end if
%>
The data sent by ASP is then retrieved by FLASH and shown in the textfields. The textfields
in FLASH have the same names as the querystring parameters.
IMPORTANT STUFF:
a) Make sure that the data is always sent as a querystring. That is why I have used
response.urlencode() method in the ASP file. This method ensures that the resultant
data is sent as a querystring.
b) The textfields in FLASH movie must have the same variable name as the querystring
parameters.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -