製作動畫時

swf檔案體積大於100k時

正妹就要製作Loading---顯示

為了讓格友更節省時間

提供下列代碼

使用時將以下原始碼放入你的FALSH第一影格即可!

var myLoading:MovieClip;
var loadInfo:MovieClip;
var _lineBgcolor = "0x666666";
var _lineColor = "0x0000FF";
var _lineLen:Number = 200;
var _lineH:Number = 3;
var _txtColor; var _txtAlign:String = "center";
var tb:Number;
var txtFormat:TextFormat = new TextFormat
("Arial", null, 0x000000, true); myLoading = _root.createEmptyMovieClip("myLoading",10); //進度條
loadInfo = myLoading.createEmptyMovieClip("line", 10);
loadInfo.lineStyle(1, _lineColor, 20);
loadInfo.moveTo(0, 0);
loadInfo.lineTo(_lineLen, 0);
loadInfo.lineTo(_lineLen, _lineH);
loadInfo.lineTo(0, _lineH);
loadInfo.lineTo(0, 0); //進度顯示文本
loadInfo.createTextField("txt", 30, 0, 0, _lineLen, 22);
loadInfo.txt.autoSize = _txtAlign; //設置進度條的位置(居中於主場景)
loadInfo._x = (Stage.width - _lineLen)/2;
loadInfo._y = Stage.height/2; //獲得影片大小並stop,再onEnterFrame
tb = _root.getBytesTotal();
_root.stop();
myLoading.onEnterFrame = function(){
  var lb:Number = _root.getBytesLoaded();
  var percent:Number = Math.round(lb/tb*100);
  loadInfo.txt.text = percent+"%";
  loadInfo.txt.setTextFormat(txtFormat);  
  loadInfo.lineStyle(_lineH, _lineBgcolor, 10);
  loadInfo.moveTo(0, _lineH/2);
  loadInfo.lineTo(percent*_lineLen/100, _lineH/2);  
  if (percent == 100) {
   _root.play();
   delete this.onEnterFrame;
   loadInfo.clear();  
   loadInfo.txt.text = "";
  }
}

 

    全站熱搜

    雞蛋貓異想世界 發表在 痞客邦 留言(1) 人氣()