利用Wipe等ActiveX技术,实现n(n>>2)幅图片轮换擦洗显示

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 qiushuiwuhen 的 blog

一般的做法,只能显示两张图片,因为wipe擦洗技术限制只能两张图片间切换。 但可以通过将两张图片转为动画交替显示

<script>
var i=0,pictures=new array();//设置图片数组
var picbase=""; //设置图片所在目录
pictures[i++]="1.gif"
pictures[i++]="2.gif"
pictures[i++]="3.gif"
pictures[i++]="4.gif"
pictures[i++]="5.gif"
pictures[i++]="6.gif"
pictures[i++]="7.gif"
pictures[i++]="8.gif"
pictures[i++]="9.gif"
pictures[i++]="10.gif"
pictures[i++]="11.gif"
pictures[i++]="12.gif"
pictures[i++]="13.gif"
pictures[i++]="14.gif"
pictures[i++]="15.gif"
pictures[i++]="16.gif"
pictures[i++]="17.gif"
pictures[i++]="18.gif"
pictures[i++]="19.gif"
pictures[i++]="20.gif"
pictures[i++]="21.gif"
pictures[i++]="22.gif"
var picturewidth=400//图片宽度
var pictureheight=290//图片高度
var delay=1//延迟时间
</script>
<script>
if (document.all) {
document.write('<object id="dacontrol_wipe" ')
document.write('style="width:'+picturewidth+';height:'+pictureheight+'"')
document.write('classid="clsid:b6ffc24c-7e13-11d0-9b47-00c04fc2f51d">')
document.write('</object>')
m = dacontrol_wipe.meterlibrary;

whattransformation = new activexobject("dximagetransform.microsoft.wipe");
whattransformation.gradientsize = 1.0;//设置渐变度
whattransformation.wipestyle = 0;//设置擦洗类型

var myarr=new array(),myarr2=new array();
var len=math.floor(pictures.length/2);//将图片分成两组
for(var i=0;i<len;i++){
myarr[i]=m.importimage(picbase+pictures[2*i])
myarr2[i]=m.importimage(picbase+pictures[2*i+1])
}
if(pictures[2*i])
myarr[i]=m.importimage(picbase+pictures[2*i])
else
myarr[i]=m.importimage(picbase+pictures[0]) ;
myarr=m.array(myarr)
myarr2=m.array(myarr2)
index = m.interpolate(0.5,len+0.5,len*2*delay).repeatforever();
index2 = m.interpolate(0,len,len*2*delay).repeatforever();
//交错运行半个时间单元
var whatpictures=new array();
whatpictures[0] = myarr.nthanim(index);
whatpictures[1] = myarr2.nthanim(index2);

forward = m.interpolate(0, 1, delay);
back = m.interpolate(1, 0, delay);
whatmovement = m.sequence(forward, back).repeatforever();
//设置参数方向

theresult = m.applydxtransform( whattransformation, whatpictures, whatmovement );
dacontrol_wipe.image = theresult.outputbvr;//设置显示图形
dacontrol_wipe.start();//开始
}
</script>

本文关键:Wipe ActiveX 多图擦洗
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top