flash向asp提交信息
做的是个填写留言的页面,这里分asp和flash两个部分!
一,asp(write.asp)部分
write.asp内容:
程序代码
<%@ LANGUAGE="VBscript" codepage="936"%>
<%
Function IDMaker
Dim ID
Randomize
ID=Replace(Year(Now)&Month(Now)&Day(Now)&Time,"-","")
ID=Replace(ID,":","")
ID=Replace(ID," ","")
ID=Replace(ID,"-","")
ID=Replace(ID,"/","")
ID=Replace(ID,"\","")
ID=Replace(ID,"上午","")
ID=Replace(ID,"下午","")
ID=Replace(ID,"PM","")
ID=Replace(ID,"AM","")
IDMaker=ID&cstr(Int(999999999*Rnd))
End Function
DataBaseName="db1.mdb"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(DataBaseName)
sub Closedb
Conn.Close
set Conn=Nothing
end sub
set rs=server.CreateObject("Adodb.recordset")
rs.open "Select top 1 * from Message",conn,2,3
rs.addnew
rs("ID")=IDMaker
rs("Name")=request.Form("myName")
rs("Email")=request.Form("myEmail")
rs("QQ")=request.Form("myQQ")
rs("Title")=request.Form("myTitle")
rs("Content")=request.Form("myContent")
rs("Addtime")=now
rs.update
rs.close
set rs=nothing
call Closedb
%>
以上是为flash和asp交互用的,上面的代码有些理解不了,有些看的懂,也解释不清楚,自己明白就行了,asp太菜没办法!
二.接下来是flash部分:
程序代码
System.useCodepage = true;//设置支持中文显示
this_mc._visible = false;//this_mc这个剪辑初始隐藏(this_mc是用了做错误提示用的)
function clean() {
this_name.text = "";
this_email.text = "";
this_qq.text = "";
this_title.text = "";
this_content.text = "";//以上代表返回清除各个文本值,设置了初始值为空!
}
clean_btn.onRelease = function() {//定义取消按纽(clean_btn)的函数
clean();
};
send_btn.onRelease = function() {//发送留言按纽函数
if (this_name.text == "") {//如果名字为空
this_mc._visible = true;//那么this.mc可见
this_mc.tishi.text = "你还没告诉我名字!";
//并且tishi.txt动态文本提示信息:姓名不能为空!
} else if (this_title.text == "") {
this_mc._visible = true;
this_mc.tishi.text = "总要有个话题吧!";
//上面三行解释为:如果剪辑title为空,那么跳出提示:主题不为空!
} else if (this_content.text == "") {
this_mc._visible = true;
this_mc.tishi.text = "你没有话和我说吗?";
//上面三行解释为:如果剪辑content为空,那么跳出提示:内容不为空!
} else {
myName = this_name.text;
myEmail = this_email.text;
myQQ = this_qq.text;
myTitle = this_title.text;
myContent = this_content.text;
trace(myName);
trace(myEmail);
trace(myQQ);
trace(myTitle);
trace(myContent);
//重点解释:trace表示输出()内各个定义的值!
loadVariablesNum("mystend.asp", 0, "POST");
//载入write.asp的asp页面
_parent.page_num = 1;
_parent.prev_btn._visible = false;
_parent.txt._visible = true;
_parent.xiala._visible = true;
_parent.next_btn._visible = true;
_parent.btn2.gotoAndStop(1);
_parent.btn1.gotoAndStop(2);
_parent.ggg = 0;
_parent.mess.unloadMovie();
_parent.mess.loadMovie("read.swf");
}
};
stop();