今天在flash gamer群与一朋友讨论组件的制作,今天在硬盘里翻了翻,找到了几个用mx2004做的组件。
这个是纯as的ProgressBar
as文件
/**
*loodingbar
*
*@作者章精设(zjs35)
*@版本
v1
*/
importfc.graphics.draw2d.Rect;
importfc.graphics.draw2d.GDI;
importfc.graphics.*;
importfc.text.DrawString;
importfc.utils.Delegate;
importfc.events.EventDispatcher;
importmx.core.UIObject;
[Event("complete")]
[Event("progress")]
[TagName("ProgressBar")]
[IconFile("ProgressBar.png")]
classProgressBarextendsUIObject{
privatevardispatchEvent:Function;
publicvaraddEventListener:Function;
publicvarremoveEventListener:Function;
privatevar_bar:GDI;
privatevar_str:DrawString;
privatevar_mc:MovieClip;
var_source:Object;
var_id:Number;
varbar:MovieClip;
publicfunctionProgressBar(){
EventDispatcher.initialize(this);
}
functiongetsource(){
returngetSource();
}
[Inspectable(defaultvalue="")]
functionsetsource(x){
setSource(x);
}
functiongetSource(Void){
return_source;
}
functionsetSource(val):Void{
if(typeof(val)=="string"){
val=eval(val);
}
if(val!=null&&val!=undefined&&val!=""){
_source=val;
//trace([_source,typeof(_source)]);
_id=setInterval(this,"setProgress",80);
dispatchEvent({type:"progress",value:0,target:this});
}
}
functionsetProgress(){
if(!_visible){
_visible=true;
}
varp1=_source.getBytesLoaded();
varp2=_source.getBytesTotal();
varp=fc.math.Num.point(p1/p2,2)*100;
_mc._xscale=p;
vars="加载"+p+"%";
dispatchEvent({type:"progress",value:p,target:this});
_str.reset(s);
if(p>=100){
dispatchEvent({type:"complete",value:_source,target:this});
clearInterval(_id);
complete();
}
}
functioncomplete(){
_bar.target=_mc;
_bar.clear();
_bar.target=this;
_bar.clear();
_str.clear();
init();
}
publicfunctioninit(){
super.init();
//width=bar._width;
//height=bar._height;
bar._visible=false;
}
functiondraw(){
//loading条的尺寸
var_w=__width;
var_h=__height;
//文本创建
_str=newDrawString();
_str.target=this;
_str.format(0x333333,"Tahoma",11);
_str.draw("加载0%");
_str.setXy(_w,(_h-_str.height)/2);
_bar=GDI.getInstance();
//背景
_bar.target=this;
_bar.fill(newSolidBrush(Color.fill,100),newRect(0,0,_w,_h));
_bar.line(newPen(1,0x919999,100),newRect(0,0,_w,_h));
_bar.line(newPen(1,0xd5dddd,100),newRect(2,2,_w-2,_h-2));
//loading条
_mc=this.createEmptyMovieClip("back",this.getNextHighestDepth());
_bar.target=_mc;
_bar.fill(newSolidBrush(Color.line,40),newRect(2,2,_w-2,_h-2));
_mc._xscale=0;
//_visible=false;
}
functionsize(){
super.size();
}
}
图示
图片如下:
600) {this.resized=true; this.width=600;}" align=baseline border=0图片如下:
600) {this.resized=true; this.width=600;}" align=baseline border=0