小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

新手學寫的flex音樂播放器

 菁清siso 2014-09-25
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
  xmlns:s="library://ns.adobe.com/flex/spark" 
  xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
  >
<!-- creationComplete="init()-->
<fx:Declarations>
<!-- 將非可視元素(例如服務、值對象)放在此處 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
private var sound:Sound = null;//建立一個音樂對象
private var soundchannel:SoundChannel = null;//建立一個聲音控制對象
private var pausePosition:int ; 
private var choose:Boolean =true;
private var flag1:Boolean =true;
private var soundlength:Number =0.1;
private var myTimer:Timer = new Timer(10, 0); 
private var thisplay:int ; 
//初始化函數(shù)
private function init():void
if(flag1)
{
sound = new Sound();//新建一個音樂對象
sound.load(new
URLRequest("http://183.213.10.72:801/videoplayer/14945107241200128.mp3?ich_u_r_i=7d14481658ab022dd5602b60d19f443a&ich_s_t_a_r_t=0&ich_e_n_d=0&ich_k_e_y=9600659c7fe4f942f9f861239d3d1ea5c130790b637d39f9bd0029d73a6c7112&ich_t_y_p_e=1096&ich_d_i_s_k_i_d=2&ich_s_e_q=2473976&ich_u_n_i_t=1"));//音樂加載地址
soundchannel = sound.play();//音樂開始播放賦值給播放權限
//添加事件偵聽器, 功能: 循環(huán)執(zhí)行 timerHandler 函數(shù)(但這里還沒有開始循環(huán)執(zhí)行)   
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);   
myTimer.start(); // 這里才開始循環(huán)執(zhí)行 timerHandler 函數(shù)   
this.addEventListener(Event.ENTER_FRAME,xunhuan);//循環(huán)獲取音樂播放進度
flag1=false;
tingzhi.enabled=true;
bofang.enabled=false;
}
}
private function stop():void
{
if(choose)
{
pausePosition = soundchannel.position;
soundchannel.stop();
choose =false;
}
}
private function huifu():void
{
if(!choose)
{
soundchannel = sound.play(pausePosition);
choose=true;
}
}
//事件循環(huán)
private function xunhuan(e:Event):void
var playbfb:Number = sound.bytesLoaded / sound.bytesTotal;//音樂加載百分比
soundlength = sound.length /playbfb;//獲取到音樂總長度
thisplay= Math.round((soundchannel.position/soundlength)*100);//音樂當前播放長
bar.setProgress(thisplay,100);//更新進度條的值
bar.label = "音樂播放"+thisplay +"%";
if(thisplay==100)
{
this.removeEventListener(Event.ENTER_FRAME,xunhuan);//我們要學會清理垃圾
}
}
private function jinduCtrl():void
{
soundchannel.stop();
soundchannel = sound.play(dragHs.value*sound.length/10);  
}
//停止音樂:   
private function stopSound():void{   
if(!flag1)
{
myTimer.stop();   
soundchannel.stop(); // 正式停止音樂   
dragHs.value = 0; // 使那"播放進度"條的值回到0,即回到最左端  
flag1=true;
tingzhi.enabled=false;
bofang.enabled=true;
}
}   
//定義被 myTimer 循環(huán)執(zhí)行的函數(shù) timerHandler   
private function timerHandler(event:TimerEvent):void{   
dragHs.value =(soundchannel.position/soundlength)*10;  
}  
]]>
</fx:Script>
<mx:ProgressBar x="70" y="78" maximum="100" minimum="0" id="bar" mode="manual"/>
<mx:HSlider id="dragHs" x="65" y="120" width="210" change="jinduCtrl()" mouseDown="myTimer.stop()" mouseUp="myTimer.start()" />
<s:Button x="71" y="191" label="暫停" click="stop()"/>
<s:Button x="200" y="147" label="繼續(xù)"  click="huifu()"/>
<s:Button x="70" y="147"  label="播放" id="bofang"  click="init()"/>
<s:Button x="200" y="191" label="停止" id="tingzhi" enabled="false" click="stopSound()"/>
</s:Application>


    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多