一个精致的loading

 

MovieClip.prototype.loadhere=function(x,y,path,name) {
   // creates and positions clip, bar and text
   trace("ss")
   var containerText=name+"text";
   var containerBar=name+"bar";
   this.createEmptyMovieClip(name,1);
   this.createEmptyMovieClip(containerText,2);
   this.createEmptyMovieClip(containerBar,3);
   this[name]._x=x;
   this[name]._y=y;
   this[containerText]._x=x;
   this[containerText]._y=y;
   this[containerBar]._x=x;
   this[containerBar]._y=y;
   // draws the bar
   with (this[containerBar]){
      beginFill (0xDDDDDD, 50);
      lineStyle (1, 0x000000, 100);
      moveTo (0, 0);
      lineTo (80, 0);
      lineTo (80, 20);
      lineTo (0, 20);
      lineTo (0,0);
      endFill();
   }
  // loads movie
   this[name].loadMovie(path);
   var movie=this[name];
   var prelText=this[containerText];
   var prelBar=this[containerBar];
  // sets new text format
   var formtext=new TextFormat();
   formtext.color="0x000000";
   formtext.font="_sans";
   formtext.align="center";
   prelText.createTextField("loadtext",50,0,0,80,20);
   prelText.loadtext.border=false;
  // defines text display
   prelText.onEnterFrame=function() {
      if(this.percent!=100) {
         this.percent=int((movie.getBytesLoaded()/movie.getBytesTotal())*100)
         this.loadtext.text="Loading "+this.percent+"%";
         this.loadtext.setTextFormat(formtext);
         prelBar._xscale=this.percent;
      }
      if(this.percent==100) {
         delete this.onEnterFrame;
         this.removeMovieClip();
         prelBar.removeMovieClip();
      }
   }
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
此代码放在放一帧上,后面帧写上:
stop()
_root.loadhere(0,0,"images\\aa.swf","center");
或:
stop()
_root.mc.loadhere(0,0,"images\\aa.swf","center");

posted on 2004-07-31 10:20  阿艺  阅读(239)  评论(0)    收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示