欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

制作Flash Loading 加載進(jìn)度條

 更新時(shí)間:2006年11月04日 00:00:00   作者:  
復(fù)制代碼 代碼如下:

前言:網(wǎng)絡(luò)中的swf影片是可以實(shí)現(xiàn)邊下載邊播放的,由于受到當(dāng)前網(wǎng)絡(luò)傳輸?shù)闹萍s,對(duì)于大容量的影片,這種實(shí)時(shí)播放并不理想。為避免受眾尷尬的等待,flash制作人員往往設(shè)計(jì)一個(gè)加載(loading)的畫面,等影片的全部字節(jié)下載到本地后再播放,從而保證影片的播放質(zhì)量.本文將介紹一種較為標(biāo)準(zhǔn)的loading制作方法。


步驟:
1.打開Flash MX 2004,選擇矩形工具,在主場(chǎng)景中畫出下一個(gè)只有邊框有矩形,本例該矩形大小為350*16像素。
2.再在主場(chǎng)景中仍用矩形工具畫出一個(gè)只有填充而無邊框的矩形,并按F8鍵將其轉(zhuǎn)換為影片剪輯(注:其注冊(cè)點(diǎn)一定要選在該矩形的最左側(cè)),其實(shí)例名為bar 。本例該矩形大小為345*11像素。
3.將上述兩矩形在主場(chǎng)景中排列好,使邊框矩形嵌套填充矩形。
4.在上述兩矩形旁邊用文字工具拖出一動(dòng)態(tài)文本框,其變量名為bar_per。

至此,準(zhǔn)備工作就緒,即建立了兩矩形框和一動(dòng)態(tài)文本框,下面準(zhǔn)備編寫代碼。

5.在主場(chǎng)景中,新建一層,選中該層第1幀,按F9鍵打開動(dòng)作腳本編輯窗口,輸入以下代碼:

this.onLoad=function(){ 
myBytesTotal=_root.getBytesTotal(); 

this.onLoad(); 
this.onEnterFrame=function(){ 
myBytesLoaded=_root.getBytesLoaded(); 
bar_xscale=myBytesLoaded/myBytesTotal*100; 
percent=Math.round(bar_xscale); 
this.bar._xscale=bar_xscale; 
this.bar_per=percent+"%"; 

if(myBytesLoaded==myBytesTotal){ 
delete this.onEnterFrame; 
_root.nextFrame(); 
}else{ 
this.stop(); 

}
6.從主場(chǎng)景時(shí)間軸第2幀起制作你的flash影片。

注解:


this.onLoad=function(){ 
myBytesTotal=_root.getBytesTotal(); 
}
此段代碼是指,當(dāng)影片剪輯(本例指兩矩形和一動(dòng)態(tài)文本框所存在的主場(chǎng)景)加載時(shí),讀取主時(shí)間軸存在的所有元素的總字節(jié)數(shù)并賦值給變量myBytesTotal。



this.onLoad(); 
flash事件處理函數(shù)MovieClip.onLoad=function(){…}有些奇怪,其中設(shè)置的代碼,若不在后面加上this.onLoad();,這些代碼并不能執(zhí)行,因此加上這一句以便這些代碼得以執(zhí)行。

myBytesLoaded=_root.getBytesLoaded();//讀取主時(shí)間軸存在的所有元素已加載的字節(jié)數(shù),并將其賦值給變量myBytesLoaded。


bar_xscale=myBytesLoaded/myBytesTotal*100;//將myBytesTotal折算成100時(shí),myBytesLoaded所得到的折算值賦給變量bar_xscale,以便給主場(chǎng)景中bar的_xscale賦值(_xscale的最大值只能為100),這里用到了初等數(shù)學(xué)的比例計(jì)算。


percent=Math.round(bar_xscale);//將變量bar_xscale的值取整后賦給變量percent,以便顯示的百分比不帶小數(shù)。

拓展:
1.“下載速度”的代碼設(shè)計(jì)
①在主場(chǎng)景中用文字工具拖出有適當(dāng)寬度的動(dòng)態(tài)文本框,并設(shè)其變量名為rate 。
②在主場(chǎng)景代碼層第1幀this.onEnterFrame=function(){}代碼體if語句前追加如下代碼:
t=getTimer();
rate= "下載速度:" + Math.round(myBytesLoaded/t * 100)/100 + " K/s";

2.“已用時(shí)間和剩余時(shí)間”的代碼設(shè)計(jì)
①在主場(chǎng)景中用文字工具拖出有適當(dāng)寬度的動(dòng)態(tài)文本框,并設(shè)其變量名為mytimes 。
②在主場(chǎng)景代碼層第1幀this.onEnterFrame=function(){}代碼體if語句前追加如下代碼:

timeLoaded=Math.round(t/1000); 
timeRemain=Math.round(timeLoaded*(myBytesTotal-myBytesLoaded)/myBytesLoaded); 
timeRemain=Math.round(timeRemain/60)+":"+Math.round(timeRemain%60); 
timeLoaded=Math.round(timeLoaded/60)+":"+Math.round(timeLoaded%60); 
mytimes="已用時(shí)間"+timeLoaded+" "+"剩余時(shí)間"+timeRemain; 
注:若“下載速度”的代碼沒有設(shè)計(jì),則上述代碼前應(yīng)追加代碼 t=getTimer();
拓展后主場(chǎng)景代碼層第1幀的全部代碼如下:


this.onLoad=function(){ 
myBytesTotal=_root.getBytesTotal(); 

this.onLoad(); 
this.onEnterFrame=function(){ 
myBytesLoaded=_root.getBytesLoaded(); 
bar_xscale=myBytesLoaded/myBytesTotal*100; 
percent=Math.round(bar_xscale); 
this.bar._xscale=bar_xscale; 
this.bar_per=percent+"%"; 

t=getTimer(); 
rate= "下載速度:" + Math.round(myBytesLoaded/t * 100)/100 + " K/s"; 

timeLoaded=Math.round(t/1000); 
timeRemain=Math.round(timeLoaded*(myBytesTotal-myBytesLoaded)/myBytesLoaded); 
timeRemain=Math.round(timeRemain/60)+":"+Math.round(timeRemain%60); 
timeLoaded=Math.round(timeLoaded/60)+":"+Math.round(timeLoaded%60); 
mytimes="已用時(shí)間"+timeLoaded+" "+"剩余時(shí)間"+timeRemain; 

if(myBytesLoaded==myBytesTotal){ 
delete this.onEnterFrame; 
_root.nextFrame(); 
}else{ 
this.stop(); 

}

相關(guān)文章

最新評(píng)論