今天在flash gamer群与一朋友讨论组件的制作,今天在硬盘里翻了翻,找到了几个用mx2004做的组件。
这个是纯as的ProgressBar
as文件
/**
* looding bar
*
* @作者 章精设(zjs35)
* @版本 v1
*/
import fc.graphics.draw2d.Rect;
import fc.graphics.draw2d.GDI;
import fc.graphics.*;
import fc.text.DrawString;
import fc.utils.Delegate;
import fc.events.EventDispatcher;
import mx.core.UIObject;
[Event("complete")]
[Event("progress")]
[TagName("ProgressBar")]
[IconFile("ProgressBar.png")]
class ProgressBar extends UIObject {
private var dispatchEvent:Function;
public var addEventListener:Function;
public var removeEventListener:Function;
private var _bar:GDI;
private var _str:DrawString;
private var _mc:MovieClip;
var _source:Object;
var _id:Number;
var bar:MovieClip;
public function ProgressBar() {
EventDispatcher.initialize(this);
}
&nb
[1] 200605/2110_2.html'>[2] 200605/2110_3.html'>[3] 200605/2110_4.html'>[4] 200605/2110_5.html'>[5] 200605/2110_2.html'>下一页
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/flash/)sp;function get source() {
return getSource();
}
[Inspectable(defaultvalue="")]
function set source(x) {
setSource(x);
}
function getSource(Void) {
return _source;
}
function setSource(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});
}
}
function setProgress() {
if (!_visible) {
_visible
200605/2110.html'>上一页 200605/2110.html'>[1] [2] 200605/2110_3.html'>[3] 200605/2110_4.html'>[4] 200605/2110_5.html'>[5] 200605/2110_3.html'>下一页
= true;
}
var p1 = _source.getBytesLoaded();
var p2 = _source.getBytesTotal();
var p = fc.math.Num.point(p1/p2, 2)*100;
_mc._xscale = p;
var s = "加载 "+p+"%";
dispatchEvent({type:"progress", value:p, target:this});
_str.reset(s);
if (p=100) {
dispatchEvent({type:"complete", value:_source, target:this});
clearInterval(_id);
complete();
}
}
function complete() {
_bar.target = _mc;
_bar.clear();
_bar.target = this;
_bar.clear();
_str.clear();
init();
}
public function init() {
super.init();
//widt
200605/2110_2.html'>上一页 200605/2110.html'>[1] 200605/2110_2.html'>[2] [3] 200605/2110_4.html'>[4] 200605/2110_5.html'>[5] 200605/2110_4.html'>下一页
h = bar._width;
//height = bar._height;
bar._visible = false;
}
function draw() {
//loading条的尺寸
var _w = __width;
var _h = __height;
//文本创建
_str = new DrawString();
_str.target = this;tulaoshi
_str.format(0x333333, "Tahoma", 11);
_str.draw("加载 0%");
_str.setXy(_w, (_h-_str.height)/2);
_bar = GDI.getInstance();
//背景
_bar.target = this;
_bar.fill(new SolidBrush(Color.fill, 100), new Rect(0, 0, _w, _h));
_bar.line(new Pen(1, 0x919999, 100), new Rect(0, 0, _w, _h));
_bar.line(new Pen(1, 0xd5dddd, 100), new Rect(2, 2, _w-2, _h-2));
//loading条
_mc = this.cre
200605/2110_3.html'>上一页 200605/2110.html'>[1] 200605/2110_2.html'>[2] 200605/2110_3.html'>[3] [4] 200605/2110_5.html'>[5] 200605/2110_5.html'>下一页
ateEmptyMovieClip("back", this.getNextHighestDepth());
_bar.target = _mc;
_bar.fill(new SolidBrush(Color.line, 40), new Rect(2, 2, _w-2, _h-2));
_mc._xscale = 0;
//_visible = false;
}
function size() {
super.size();
}
} 图示
图片如下:
图片如下:
200605/2110_4.html'>上一页 200605/2110.html'>[1] 200605/2110_2.html'>[2] 200605/2110_3.html'>[3] 200605/2110_4.html'>[4] [5]
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/flash/)