flash端的程序非常簡(jiǎn)單只有三行:
//在時(shí)間軸的第一幀,加入下面的代碼 //標(biāo)簽名稱為"開始投票吧!"的按鈕,事件句柄為sendvote,在點(diǎn)擊后執(zhí)行下面的自定義函數(shù) function sendvote () { _root.mytb.readData("http://localhost/votexml.asp?selectresult="+radioGroup.getInstance()); }
服務(wù)器端程序的編寫,上面你可能看到有一個(gè)votexml.asp的文件,下面我們就來(lái)建立它. 代碼如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <% set conn=server.CreateObject("adodb.connection") conn.open "dsn=mysql" set rec=server.CreateObject("adodb.recordset") %> <% if request("selectresult")<>"" then userip= Request.ServerVariables("REMOTE_ADDR") selectresult=request.QueryString("selectresult") rec.open "select count(*) as count from votetable where votedate>'"&now()-0.125 & "' and userip='"&userip&"'",conn if rec("count")>0 then bzh="重復(fù)投票無(wú)效" rec.close 'response.Write("請(qǐng)不要重復(fù)投票") else rec.close bzh="投票有效" conn.execute "insert into votetable(userip,result) values('"&userip&"',"& selectresult&")" end if else bzh="查看投票" end if rec.open "SELECT result,count(*) as count FROM votetable group by result ORDER BY result asc",conn t0=cint(rec("count")) rec.movenext t1=cint(rec("count")) rec.movenext t2=cint(rec("count")) tcount=t0+t1+t2 Response.contenttype="text/xml" %> <% Response.write "<?xml version='1.0' encoding='gb2312'?>" response.Write("<root bz='"&bzh&"'>") Response.write "<base><data value='相信' color='0xff00cc'/><data value='不相信' color='0x0000CC'/><data value='現(xiàn)在還不清楚' color='0x00cc00'/></base>" response.Write("<record value='共"&tcount&"票' color='0x0000CC'>") response.Write("<data value='"&t0/tcount&"'/>") response.Write("<data value='"&t1/tcount&"'/>") response.Write("<data value='"&t2/tcount&"'/></record>") %> <% Response.write "</root>" rec.close set rec=nothing conn.close set conn=nothing %>
將文件保存為votexml.asp,放置到web路徑為"/"的目錄中,即可.
備注,實(shí)際應(yīng)用到web服務(wù)器的時(shí)候,請(qǐng)?jiān)趂lash中使用相對(duì)路徑.flash movie和votexml.asp可以放置到任何目錄中.
出處:藍(lán)色理想
責(zé)任編輯:qhwa
上一頁(yè) 問(wèn)題分析和界面設(shè)計(jì) 下一頁(yè)
◎進(jìn)入論壇Flash專欄版塊參加討論
|