一般的做法,只能顯示兩張圖片,因為Wipe擦洗技術(shù)限制只能兩張圖片間切換花。 但可以通過將兩張圖片轉(zhuǎn)為動畫交替顯示
<script> var i=0,pictures=new Array();//設(shè)置圖片數(shù)組,圖片數(shù)為奇數(shù) 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;//設(shè)置漸變度 whatTransformation.WipeStyle = 0;//設(shè)置擦洗類型
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(); //設(shè)置參數(shù)方向
theResult = m.ApplyDXTransform( whatTransformation, whatPictures, whatMovement ); DAControl_Wipe.Image = theResult.OutputBvr;//設(shè)置顯示圖形 DAControl_Wipe.Start();//開始 } </script>
使用的技巧區(qū)別于以往的主要在將圖片交替轉(zhuǎn)為兩個數(shù)組,利用內(nèi)部計數(shù)Interpolate和NthAnim技術(shù)實現(xiàn)動畫。
出處:視覺中國
責(zé)任編輯:藍色
◎進入論壇網(wǎng)頁制作、網(wǎng)站綜合版塊參加討論
|