創(chuàng)建自己的ProgressBar組件_Flash教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:平滑播放FLV視頻文件一直覺(jué)得flash播放視頻文件不是很理想,除需要轉(zhuǎn)換常用的MPG、AVI為FLV的麻煩不說(shuō),單是播放FLV文件時(shí)那“馬賽克”(實(shí)時(shí)是縮放播放時(shí)沒(méi)有經(jīng)過(guò)抗鋸齒處理)很不舒
今天在flash gamer群與一朋友討論組件的制作,今天在硬盤(pán)里翻了翻,找到了幾個(gè)用mx2004做的組件。這個(gè)是純as的ProgressBar
as文件
/**
* looding bar
*
* @作者 章精設(shè)(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);
}
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 = 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();
//width = bar._width;
//height = bar._height;
bar._visible = false;
}
function draw() {
//loading條的尺寸
var _w = __width;
var _h = __height;
//文本創(chuàng)建
_str = new DrawString();
_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(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.createEmptyMovieClip("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();
}
} 圖示
圖片如下:
圖片如下:
分享:用MovieClipLoader連續(xù)加載外部圖片并進(jìn)行控制也不記得在那個(gè)高手的blog上看到過(guò)。學(xué)習(xí)過(guò),這里有人問(wèn)起那就拿來(lái)用一用了,(整理出來(lái))代碼如下:varselectedmc;varid=1;varNum=13;varmyML:MovieCli
相關(guān)Flash教程:
- as中禁用ESC鍵
- AS3.0 圖片變黑白 圖片彩色變黑白代碼
- flash as3.0 跨域的解決辦法
- 模板無(wú)憂FLASH透明代碼
- Flash教你制作卡通MM眨眼睛動(dòng)畫(huà)
- Flash從零開(kāi)始學(xué)習(xí)創(chuàng)建單選按鈕
- Flash繪制小龍與花插畫(huà)場(chǎng)景
- Flash程序的測(cè)試方法
- Flash CS4文字顏色緩動(dòng)特效
- 網(wǎng)頁(yè)中演示類FLASH動(dòng)畫(huà)制作規(guī)范
- Flash CS3循環(huán)背景的運(yùn)用技巧
- Flash鼠繪技巧教你制作紅綠色的樹(shù)葉
Flash教程Rss訂閱網(wǎng)站制作教程搜索
Flash教程推薦
- Flash Player 10新特性:Vector
- Flash MX2004入門(mén)與進(jìn)階實(shí)例——?jiǎng)幼髂_本(5)
- Flash中用鍵盤(pán)控制影片剪輯的兩種方法
- Flash MX2004入門(mén)與進(jìn)階實(shí)例--動(dòng)畫(huà)基礎(chǔ)(25)
- Flash片頭loading與V2組件相關(guān)問(wèn)題
- 打造一個(gè)完美的共享庫(kù)
- Flash MX2004入門(mén)與進(jìn)階實(shí)例——元件和實(shí)例(5)
- Flash MX2004入門(mén)與進(jìn)階實(shí)例--動(dòng)畫(huà)基礎(chǔ)(29)
- 用純Flash Actionscript做的火柴棍小人跑的動(dòng)畫(huà)
- 用Flash AS制作時(shí)鐘(Date類)
猜你也喜歡看這些
- Flash 8經(jīng)典動(dòng)畫(huà)設(shè)計(jì)實(shí)錄
- Adobe Flash CS5 新增功能課程
- Flash8全實(shí)例學(xué)習(xí)手冊(cè)原書(shū)配套光盤(pán)
- Flash AS3.0教程之類入門(mén)到精通
- 新東方任汝芬考研政治大綱解析班flash視頻及其他
- Flash 8完美動(dòng)畫(huà)設(shè)計(jì)與制作
- 金鷹FLASH CS3活學(xué)活用
- Flash CS4動(dòng)畫(huà)設(shè)計(jì)與制作300例
- 中科院新科海Flash培訓(xùn)視頻
- 金鷹Flash ActionScript編程視頻教程 swf
- 相關(guān)鏈接:
- 教程說(shuō)明:
Flash教程-創(chuàng)建自己的ProgressBar組件
。