| 首页 | 新闻 | 网页 | 设计 | 色彩 | 原创 | 视觉 | 素材 | 动漫 | 酷站 | 策划 | 文案 | 访谈 | 运营 | 编程 | 数据库 | 服务器 | 下载 | 图库 | 
您的位置: 幽幽天空 > 网页 > 网页制作 > Flash教程 > ActionScript教程 > 文章正文 用户登录
一段小代码实现的
一段代码引发杀毒
一段使用 iptable
一段精简的使用 A
一段php加密解密的
怎么样写一段高效
将汉字转换成汉语
ASP创建EXCHANGE用
一段返回随机记录
利用MSCHART画图的

一段精致的loading代码           

一段精致的loading代码

作者:佚名 来源:不详 更新:2007-1-13 20:48:13 错误报告 我要投稿
全部AS完成。

 MovieClip.prototype.loadhere=function(x,y,path,name){
 //createsandpositionsclip,barandtext
 varcontainerText=name+"text";
 varcontainerBar=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;
 //drawsthebar
 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();
 }
 //loadsmovie
 this[name].loadMovie(path);
 varmovie=this[name];
 varprelText=this[containerText];
 varprelBar=this[containerBar];
 //setsnewtextformat
 varformtext=newTextFormat();
 formtext.color="0x000000";
 formtext.font="_sans";
 formtext.align="center";
 prelText.createTextField("loadtext",50,0,0,80,20);
 prelText.loadtext.border=false;
 //definestextdisplay
 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){
 deletethis.onEnterFrame;
 this.removeMovieClip();
 prelBar.removeMovieClip();
 }
 }
 }

 以上代码都在主场景第一桢。如要此代码工作该如何设置?举个例子:
 比如你要load一个jpg(name:mm)或者一个swf(name:gg)
 则可以在主场景中创建一个空MC(instancename:mc)(或者直接load进主场景)然后在桢1中加如下代码:

 _root.mc.loadhere(0,0,"mm.jpg","mm");或者_root.mc.loadhere(0,0,"gg.swf","gg");

 以后你若想LOADjip或者swf都可以直接使用上面的代码,你还可以改变进度条的颜色,大小等,很方便。需要指出的是,在本地无法观看效果。有空间的朋友可以试一试。
文章录入:skyuu    责任编辑:skyuu 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
    姓名:  评 分: 1分 2分 3分 4分 5分
     
  • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
  • 用户需对自己在使用幽幽天空服务过程中的行为承担法律责任。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表机友个人观点,与本网站立场无关。