as2.0脚本怎样做“加载中”

var myLoading:MovieClip;

var loadInfo:MovieClip;

var _lineBgcolor = "0x9933FF"; //进度条颜色

var _lineColor = "0x0000FF"; //进度框颜色

var _lineLen:Number = 500;// 用函数设置进度条进度框宽度

var _lineH:Number = 5; // 用函数设置进度条进度框高度

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 = 303;

//设置进度条进度框的X位置

loadInfo._y = 438;

//设置进度条进度框的Y位置

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

  }

}

]]>

你可能感兴趣的:(AS2)