一个傻瓜式显示下载进度的代码

  • 来源: 中国IT实验室 作者: somesun   2008-03-18/09:57
  • //创建动态文本
    this.createTextField("my_txt", 0, 0, 0, 0, 0);
    with (my_txt) {
     autoSize = true;
     _x = 170;
     _y = 180;
    }
    //画背景矩形框
    this.createEmptyMovieClip("frame_mc", 1);
    with (frame_mc) {
     beginFill(0x000000);
     moveTo(0, 0);
     lineTo(202, 0);
     lineTo(202, 4);
     lineTo(0, 4);
     lineTo(0, 0);
     endFill();
     _x = 174;
     _y = 200;
    }
    //画矩形
    this.createEmptyMovieClip("bar_mc", 2);
    with (bar_mc) {
     beginFill(0xFFFFFF);
     moveTo(0, 0);
     lineTo(200, 0);
     lineTo(200, 2);
     lineTo(0, 2);
     lineTo(0, 0);
     endFill();
     _x = 175;
     _y = 201;
     _visible = 0;
    }
    //进度动画显示
    var loaded:Number = 0;
    bar_mc.onEnterFrame = function() {
     this._visible = 1;
     loaded = Math.floor(getBytesLoaded()/getBytesTotal()*100);
     if (loaded>=100) {
      bar_mc.removeMovieClip();
      frame_mc.removeMovieClip();
      my_txt.removeTextField();
      gotoAndStop(2);
     } else {
      bar_mc._xscale = loaded;
      my_txt.text = loaded+"%";
      my_txt._x = 170+loaded*2;
     }
    };

    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多