当前位置:软件学习 > Flash >>

as3 loading加载效果代码

 代码如下 复制代码

class Loader extends MovieClip{
private var loaded:Number;
private var loadtxt:TextField;
private var loadline:MovieClip;

function Loader(){
loadstart();
}
function loadstart(){
/*createEmptyMovieClip( “loadline”, 1 );
with (loadline)
{
lineStyle( 1, 0xff00ff, 100 );
moveTo( _root._x, _root._y);
lineTo( _root._x,_root._y+_root._width);
lineTo( _root._x+_root._height,_root._y+_root._width);
lineTo( _root._x+_root._height,_root._y);
lineTo( _root._x, _root._y);
}*/
createTextField(“loadtxt”,10000, _root._x, _root._y-20, 0, 0, 0);
with(loadtxt){
autoSize = “left”;
background = true;
backgroundColor = 0xffffff;
border = true;
borderColor = 0×000000;
selectable = false;
}
var tf:TextFormat = new TextFormat();
tf.size = 10;
tf.font = “Courier”;
tf.color = 0×000000;
loadtxt.setNewTextFormat(tf);
this.onEnterFrame=compute_load;
}
function compute_load(){
loaded=_root.getBytesLoaded()/_root.getBytesTotal();
loadtxt.text=“total:”+int(_root.getBytesLoaded()/1024)+“/”+int(_root.getBytesTotal

()/1024)+“k “+“loaded:”+int(loaded*100)+“%”;
this._xscale=loaded*100;
if(loaded>=1){
delete this.onEnterFrame;
this.unloadMovie();
_root.play();
}
}
}

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,