asp学习

慢慢成长,知识是靠积累的,经验最重要!

导航

flash图片轮换广告代码详解


以下是本人在实际建站过程中用到的asp带数据库的flash的图片轮换广告,非常实用!
下面将实现步骤详述如下,希望能给大家带来帮助!
首先建立一个数据表,tbl_news,主要字段有id,title,picurl,content,istop,orderid等等
<SCRIPT type=text/javascript>
<!--
//格式初始化
var focus_width = 240;//大小可以随意改变
var focus_height = 170;
var text_height = 18;
var swf_height = focus_height + text_height;
//获得相关图片
<%
'读取数据库,这里的8可以根据需要更改,istop是推荐字段,可以控制显示的内容,orderid是排序字段!
sql="select top 8 * from tbl_news where istop1=1 order by orderid desc"
set rsnews=conn.execute(sql)
m=0
'循环写入变量
do while not rsnews.eof
picurl="upload/images/"&rsnews("picurl")
title=cutstr(rsnews("title"),30)
if m=0 then '只有一条记录时
pics=picurl
links=server.UrlEncode("newsinfo.asp?id="&rsnews("id"))
texts=title
else '多条记录时
pics=picurl&"|"&pics
links=server.UrlEncode("newsinfo.asp?id="&rsnews("id")&"|"&links
texts=title&"|"&texts
end if
m=m+1
rsnews.movenext
loop
%>
'下面的images/player.swf,填写正确的地址就可以使用了
var pics = "<%=pics%>";
var links = "<%=links%>";
var texts = "<%=texts%>";
//输出调用代码
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="images/player.swf"><param name="quality" value="high"><param name="bgcolor" value="#E3E3E3">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
document.write('<embed src="images/player.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#E3E3E3" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
-->
</SCRIPT>
player.swf

posted on 2007-11-20 21:34  laopu  阅读(1172)  评论(0)    收藏  举报