JS+Flash实现首页图片切换幻灯片效果
 
代码如下:
 
<script language='javascript'>
linkarr = new Array();//获取连接地址的数组
picarr = new Array();//获取图片地址的数组
textarr = new Array();//获取连接标题的数组
var focus_width=330;//图片的宽度
var focus_height=280;//图片的宽度
var text_height=17;//文字的高度
var pics = "";
var links = "";
var texts = ""; //pics,link,texts分别图片路径,链接地址,和链接标题
var swf_height = focus_height+text_height;//flash的高度
var defJpeg = "jpg.jpg";//背景图片,当没有图片的时侯显示
//获取图片路径,链接地址,和链接标题
{dede:arclist type='image.' row='5' orderby=pubdate typeid=1}
linkarr[[field:global name=autoindex/]] = "[field:arcurl/]";
picarr[[field:global name=autoindex/]] = "[field:picname/]";
textarr[[field:global name=autoindex/]] = "[field:title/]";
{/dede:arclist}
 
 
for(i=1;i<picarr.length;i++){
  if(picarr[i].indexOf("jpg")==-1 && picarr[i].indexOf("JPG")==-1) picarr[i] = defJpeg;
  if(pics=="") pics = picarr[i];
  else pics += "|"+picarr[i];
}
for(i=1;i<linkarr.length;i++){
  if(links=="") links = linkarr[i];
  else links += "|"+linkarr[i];
}
for(i=1;i<textarr.length;i++){
  if(texts=="") texts = textarr[i];
  else texts += "|"+textarr[i];
}
/*
//以上for结构形成如下的结构
var pics='/pic/001.jpg|/pic/005.jpg|/pic/007.jpg';
var links='http://www.baidu.com/|[url]http://www.163.com/[/url]|[url]http://www.126.com/[/url]';
var texts='图1|图2|图3'
*/
 
 
 
//调用flash
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="flash.swf">');
document.write('<param name="quality" value="high"><param name="bgcolor" value="#ffffff">');
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="flash.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#ffffff" 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> 
 
 
另外需要注意的是:
1、修改要下载flash.swf文件
2、本地测试要假设WEB服务器,而且,图片路径只支持 网站根目录下起始路径