Anonymous
Anonymous asked in 電腦與網際網路程式設計 · 2 decades ago

請高手幫忙看一下這個JavaScript........急

我在網路中找到這個JavaScript,我也有套用到html中,也能使用...

但是這個JavaScript卻只能讓兩張相片換來換去....

我想套用4~6張相片做效果.....=.=|||可是研究了一整晚還是弄不出來...

麻煩會的人幫忙改看看...或解說一下....謝謝

<script>

// the name of your first picture-file

var picture1="042.gif"

// the name of your second picture-file

var picture2="043.gif"

// the name of your second picture-file

var picture2="044.gif"

// the width and height of your pictures (pixels)

var picturewidth=220

var pictureheight=244

</script>

===============(以上放在<head>和</head>之間)=====================

===============(以下放在<body>和</body>之間)=====================

<script language="JavaScript">

<!--

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");

whatPictures = new Array();

whatPictures[0] = m.ImportImage(picture1);

whatPictures[1] = m.ImportImage(picture2);

forward = m.Interpolate(0, 1, 3);

back = m.Interpolate(1, 0, 2);

whatMovement = m.Sequence(forward, back).RepeatForever();

whatTransformation.GradientSize = 1.0;

whatTransformation.WipeStyle = 0;

theResult = m.ApplyDXTransform( whatTransformation, whatPictures, whatMovement );

DAControl_Wipe.Image = theResult.OutputBvr;

DAControl_Wipe.Start();

}

//-->

</script>

1 Answer

Rating
  • Anonymous
    2 decades ago
    Favorite Answer

    <script>

    var i=0,pictures=new Array();//設定圖片路徑

    var picbase="";

    pictures[i++]="01.jpg"

    pictures[i++]="02.jpg"

    pictures[i++]="03.jpg"

    pictures[i++]="04.jpg"

    pictures[i++]="05.jpg"

    pictures[i++]="06.jpg"

    pictures[i++]="07.jpg"

    var picturewidth=400 //顯示圖片寬度

    var pictureheight=290 //顯示圖片高度

    var delay=2 //照片換張延遲時間

    </script>

    <body>

    <script language="JavaScript">

    <!--

    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>

    </body>

Still have questions? Get your answers by asking now.