欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Flash與數(shù)據(jù)庫(kù)的連接方法與代碼

 更新時(shí)間:2007年03月20日 00:00:00   作者:  
確切地說(shuō)..flash是不可以直接與數(shù)據(jù)庫(kù)連接的.只能是通過(guò)ASP...所以呢.首先,先在ASP里編寫好連接數(shù)據(jù)庫(kù)的語(yǔ)句
復(fù)制代碼 代碼如下:

<%  
dim cn  
dim connstr  
dim db  
db="asp.mdb"  
Set cn = Server.CreateObject("ADODB.Connection")  
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")  
cn.Open connstr  
%> 

存儲(chǔ)為cn.asp文件;
第二步;就編寫一個(gè)讀取數(shù)據(jù)庫(kù)數(shù)據(jù)的ASP文件嘍... 
復(fù)制代碼 代碼如下:

<!--#include file="cn.asp"-->  
<%  
set rs=server.createobject("adodb.recordset")  
rs.open "select * from class ",cn,3,3  
for i=1 to rs.recordcount  
if not rs.eof then  
totalClass=totalClass&rs("Class")&","  
totalLink=totalLink&rs("classlink")&","  
rs.movenext()  
end if  
next  
response.write ("flashClass="&totalClass&"&")  
response.write ("flashLink="&totalLink&"&") 
'注意這個(gè)寫格式.多個(gè)參數(shù)得用&這個(gè)來(lái)連接.有些人會(huì)忽略到這一點(diǎn).導(dǎo)致在flash不能寫出數(shù)據(jù)來(lái).  %> 
 

將這個(gè)文件存儲(chǔ)為:write.asp
第三步;回到flash那里來(lái)編寫語(yǔ)句.把write.asp文件加載進(jìn)來(lái).
第一幀:
System.useCodepage=true; 
var newload = new LoadVars();//如果不是很了解這個(gè)LoaVars,可以去查一下那個(gè)flash里面的幫助文檔 
newload.load("write.asp"); 
newload.onLoad = function(success) { 
if (success) { 
_root.gotoAndStop(2);//當(dāng)文件被加載完成后,執(zhí)行第二幀. 

}; 
stop();//這里要注意.如果不用停止.假設(shè)文件還沒(méi)有加載完就執(zhí)行第二幀...而在第二幀是在flash里讀取數(shù)據(jù)的.那就導(dǎo)致讀不出數(shù)據(jù)
第二幀:
_root.name.text = newload.flashClass;//下面兩句是讀取數(shù)據(jù)的. 
_root.link.text = newload.flashLink; 
_root.bt._visible = false;//是一個(gè)影片的名字,里面放有一個(gè)動(dòng)態(tài)文本bttext 
//現(xiàn)在就把數(shù)據(jù)放到數(shù)組中去.... 
var aspclass = newload.flashClass; 
var link = newload.flashLink; 
var Aclass = new Array(); 
var Blink = new Array(); 
for (i=0; i<aspclass.length; i++) { 
Aclass = aspclass.split(",", i); 
Blink = link.split(",", i); 

for (i=0; i<Aclass.length-1; i++) { 
//for (i=1; i<6; i++) { 
_root.bt.duplicateMovieClip("bt"+i, i); 
_root["bt"+i]._y = i*30; 
_root["bt"+i]._x = 5; 
_root["bt"+i].url = Blink; 
_root["bt"+i].bttext.text = Aclass; 
_root["bt"+i].onRelease = function() { 
_root.link2.text = this.url; 
getURL("http://"+this.url,"_blank"); 
}; 

相關(guān)文章

最新評(píng)論