且行资源

关注信息技术在教学中应用,专业教学资源设计开发。

上一篇: 网页设计应当知道的XHTML教程 下一篇:Powerpoint中的声音控制

第一种:在显示加载进度,而且可以用来加载 图片或其它swf文档。使用方法
   1,把以下代码放在第一帧
   2,建立一个空的影片剪辑,放到第一帧,并起名字mc(可以随便起,使用名字引用这个影片剪辑,做为加载的容器使用)
   3,加载jpg图片的话,则加 _root.mc.loadhere(0,0,"mm.jpg","mm")代码 0,0是图片加载的位置,mm.jpg是图片文件名和路径
  4,加载swf文件则使用以下代码:_root.mc.loadhere(0,0,"gg.swf","gg") 含义与图片相同
代码如下:
   MovieClip.prototype.loadhere=function(x,y,path,name) {
// creates and positions clip, bar and text
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();
}
}
}

第二种:矩形框显示进度,只要放在第一帧就可以了,你也可以调整位置。即rect1 rect2的_x _y的值
stop();
var rect1:MovieClip = createRectangle1(150, 3, 0x000000);
var rect2:MovieClip = createRectangle2(152, 5, 0x000000);
rect1._x = (Stage.width - rect1._width) / 2;
rect1._y = (Stage.height - rect1._height) / 2;
rect2._x = (Stage.width - rect2._width) / 2;
rect2._y = (Stage.height - rect2._height) / 2;
onEnterFrame = function () {
rect1._width = _root.getBytesLoaded() / _root.getBytesTotal() * 150;
if (_root.getBytesLoaded() == _root.getBytesTotal()) {
rect1.removeMovieClip();
rect2.removeMovieClip();
delete rect1;
delete rect2;
delete createRectangle1;
delete createRectangle2;
delete onEnterFrame;
play();
}
};
function createRectangle1(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}
function createRectangle2(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip {
scope = (scope == undefined) ? this : scope;
var depth:Number = scope.getNextHighestDepth();
var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
mc.lineStyle(color);
mc.moveTo(0, 0);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);
return mc;
}


如何订阅

点击这里获取该日志的TrackBack引用地址

相关文章:   或许你还对下面的文章感兴趣

 

 

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于本文|

您正在阅读的是:flash的loading代码研究
版权声明:请以超链接形式标明文章原始出处和作者信息
http://www.qiexing.com/post/427.html



最近发表

最新评论及回复

最近留言

网站分类


文章归档

且行资源 版权所有西部数码提供虚拟主机 Powered By Z-Blog 1.8 Spirit Build 80710

联系方式:sunfang@qiexing.com QQ:510280445 电话:013955453231
转载本站内容必须也遵循“署名-非商业用途-保持一致”的创作共用协议. 皖ICP备07002369号