利用圖片播放前端
<div class="wrap" id="wrap" style="position: inherit; height: 604px;"> <div class="main"> <script src="http://www.zaidu.sn.cn/zaidu/刺激戰場爭霸賽3/js/canvas.js"></script> <div id="loading" class="compatibleStyle"> <div id="startPlay" style="display: none">開始刺激時刻</div> <canvas id="clgass" width="128" height="128"></canvas> <script> var frame_Imgs_1=['run_1.png','run_2.png','run_3.png','run_4.png','run_5.png','run_6.png','run_7.png','run_8.png','run_9.png','run_10.png','run_11.png','run_12.png','run_13.png','run_14.png','run_15.png','run_16.png',]; //新建動畫實例 var cfa1=new canvasfa({ cav:'clgass'//canvas畫布id ,frames:frame_Imgs_1//幀動畫的素材 ,url:'http://www.zaidu.sn.cn/demo/zaidu_03/img/'//圖片路徑 ,fps:24//【可選參數】每秒幀數,默認每秒15幀。(液晶屏每秒刷新60次,因此幀數最好是能夠整除60的數) ,loop:true//【可選參數】循環播放,false則單次播放並停留在最後一幀,true和默認是循環播放 //,autoplay:false//【可選參數】素材加載完畢後是否自動播放; false不播放,true和默認是自動播放。可用 實例對象.start()手動開啓播放 //,loading_done:alert1//【可選參數】參數須要是一個函數,在素材加載完畢後運行。可缺省此參數。 }); //開始 var _PageHeight = document.documentElement.clientHeight, _PageWidth = document.documentElement.clientWidth; //計算loading框距離頂部和左部的距離(loading框的寬度爲215px,高度爲61px) var _LoadingTop = _PageHeight > 61 ? (_PageHeight - 61) / 2 : 0, _LoadingLeft = _PageWidth > 215 ? (_PageWidth - 215) / 2 : 0; //在頁面未加載完畢以前顯示的loading Html自定義內容 var _LoadingHtml = document.getElementById("clgass"); //呈現loading效果 /*'<div id="loadingDiv" style="position:absolute;left:0;width:100%;height:' + _PageHeight + 'px;top:0;background:#f3f8ff;opacity:1;filter:alpha(opacity=80);z-index:10000;"><div style="position: absolute; cursor1: wait; left: ' + _LoadingLeft + 'px; top:' + _LoadingTop + 'px; width: auto; height: 57px; line-height: 57px; padding-left: 50px; padding-right: 5px; background: #fff url(Image/loading.gif) no-repeat scroll 5px 10px; border: 2px solid #95B8E7; color: #696969; font-family:\'Microsoft YaHei\';">頁面加載中,請等待...</div></div>'*/ document.write(_LoadingHtml); //window.onload = function () { // var loadingMask = document.getElementById('loadingDiv'); // loadingMask.parentNode.removeChild(loadingMask); //}; //監聽加載狀態改變 document.onreadystatechange = completeLoading; //加載狀態爲complete時移除loading效果 function completeLoading() { if (document.readyState == "complete") { var loadingMask = document.getElementById('loading'); loadingMask.parentNode.removeChild(loadingMask); } } </script> </div>