论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Flash AS编程教程
Tag:2.0,3.0菜鸟,游戏,,cs,技巧,源码,,文本,文字,函数,音乐,随机,拖拽,asp,access,xml,mc,视频教程

mp3播放器 (as 3.0)

文章类别:Flash AS编程 | 发表日期:2008-10-6 18:37:05


版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://wxsr.blogbus.com/logs/13558137.html







 

 

stop();
var SelectedObj={};
SelectedObj.down=false;
SelectedObj.selecte=null;
SelectedObj.selecteBool=false;
SelectedObj.inx=0;
SelectedObj.DoubleClick=0;
SelectedObj.Next=true;
edit_tool.Member_ID=lister.imd;
var aList:List = new List();
var sinkList:List = new List();
sink.close_btn.addEventListener(MouseEvent.CLICK,close_fco);
sink.min_btn.addEventListener(MouseEvent.CLICK,min_fco);
sink.close_btn.addEventListener(MouseEvent.MOUSE_OVER, over_fco);
sink.min_btn.addEventListener(MouseEvent.MOUSE_OVER, over_fco);
function over_fco(event:MouseEvent):void {
 load_obj.MoveBool=false;
}

function close_fco(event:Event) {
 
}
function min_fco(event:Event) {
 
}
var list_member_arr=[edit_tool,delete_tool,barTool,delete_btn,add_btn,edit_btn,barTool2,aList];
var sink_member_arr=[sinktool1,sinktool2,sinkList];
sink.mc.list_member_arr=list_member_arr;
sink.mc.sink_member_arr=sink_member_arr;
for (var t=0; t<list_member_arr.length; t++) {
 list_member_arr[t].visible=false;
}
for (var t_=0; t_<sink_member_arr.length; t_++) {
 sink_member_arr[t_].visible=false;
}
var member:Array=[];
var load_obj:Loader_Img=new Loader_Img("http://daxue.goqo.com/swf/MP3Player/Skin/sink1.swf",sink.mc,SoundList,aList);
//var load_obj2:Loader_Img=new Loader_Img("sink1.swf",mc,soundList);
//var lcSender:LCSender=new LCSender(load_obj);

var sink_arr=[["黑色经典","http://daxue.goqo.com/swf/MP3Player/Skin/sink1.swf"]];
sinkList.setSize(129, 110);
aList.setSize(200, 210);
var format:TextFormat = new TextFormat();
format.color = 0xffffff;
format.size = 12;
aList.setRendererStyle("textFormat", format);
sinkList.setRendererStyle("textFormat", format);
aList.rowCount=10;
sinkList.rowCount=5;
//////////////////////////////////
for (var i_=0; i_<sink_arr.length; i_++) {

 sinkList.addItem({label:(i_+1)+'.'+sink_arr[i_][0], data:sink_arr[i_][1]});
}
for (var i=0; i<soundList.length; i++) {
 var str=(i+1)+"."+soundList[i].label.substr(0,15);
 if (soundList[i].length>15) {
  str+="......";
 }
 if (i==0) {

  SelectedObj.id={label:str,data:soundList[i].link,info:soundList[i].info,id:i};
 }
 aList.addItem({label:str, data:soundList[i].link,info:soundList[i].info,id:i});
}

 

 

//aList.move(10,100);

addChild(aList);
addChild(sinkList);

aList.addEventListener(fl.events.ListEvent.ITEM_ROLL_OVER,Cover);
aList.addEventListener(fl.events.ListEvent.ITEM_ROLL_OUT,Cout);
aList.addEventListener(MouseEvent.MOUSE_DOWN,GetMouseDown_Func);
aList.addEventListener(MouseEvent.MOUSE_UP,GetMouseUp_Func);
sinkList.addEventListener(ListEvent.ITEM_CLICK  , down);
function down(e:ListEvent) {
 var list:List = e.target as List;
 var item:Object = e.item;
 load_obj.ChangSink(item.data);

}
function GetMouseDown_Func(event:Event) {
 SelectedObj.down=true;
 SelectedObj.id=SelectedObj.Tmp;


}
function GetMouseUp_Func(event:Event) {

 SelectedObj.DoubleClick++;
 var timer:Timer=new Timer (200);
 timer.addEventListener("timer",lis);
 timer.start();
 if (SelectedObj.DoubleClick==2) {
  SelectedObj.DoubleClick=0;
  var list_arr=[];
  for (var i=0; i<aList.length; i++) {
   list_arr.push(aList.getItemAt(i).data);
  }
  load_obj.PlaySelected(SelectedObj.inx,list_arr);

 } else if (SelectedObj.Change) {
  var SaveSoundList="&lt;FileList&gt;";
  aList.removeItem(SelectedObj.id);

  aList.addItemAt(SelectedObj.id,SelectedObj.selecte);
  for (var j=0; j<aList.length; j++) {
   var str=aList.getItemAt(j).label;
   var newStr=str.substr(str.indexOf("."),str.length);
   str=aList.getItemAt(j).label=(j+1)+newStr;
   SaveSoundList+=aList.getItemAt(j).info;
  }
  SaveSoundList+="&lt;/FileList&gt;";
  //trace(SaveSoundList)
  savePlayList(SaveSoundList);

 }
 SelectedObj.Change=false;
 //SelectedObj.id=null;

}


function Cout(e:ListEvent):void {
 var list:List = e.target as List;
 var item:Object = e.item;

}

function Cover(e:ListEvent):void {
 var list:List = e.target as List;
 var item:Object = e.item;
 SelectedObj.Tmp= item;
 if (SelectedObj.down) {

  SelectedObj.Change=true;
 } else {
  SelectedObj.Change=false;
 }
 var cr:CellRenderer = e.target.itemToCellRenderer(e.item) as CellRenderer;
 var listData:ListData = cr.listData;
 SelectedObj.selecte=listData.row;
 SelectedObj.inx=listData.row;
}

////////////////////////////////////////////


function lis(event:TimerEvent) {

 SelectedObj.DoubleClick=0;
 event.target.stop();
}


aList.move(barTool.x-1,barTool.y+barTool.height-1);
sinkList.move(aList.x+200,aList.y);
sinktool1.x=sinktool2.x=sinkList.x;
sinktool1.y=sinkList.y+1-sinktool1.height;
sinktool2.y=sinkList.y+sinkList.height;
edit_tool.y=delete_tool.y=sinktool2.y+sinktool2.height;
edit_tool.x=delete_tool.x=sinktool2.x;
barTool2.x=barTool.x;

barTool2.y=aList.y+aList.height;

add_btn.y=delete_btn.y=edit_btn.y=aList.y+aList.height+(barTool2.height-add_btn.height)/2;
barTool.members=[edit_tool,delete_tool,barTool,delete_btn,add_btn,edit_btn,barTool2,aList];
sinktool1.members=[sinktool1,sinktool2,sinkList];
sinktool1.close_btn.addEventListener(MouseEvent.CLICK,closeFunc);
barTool.close_btn.addEventListener(MouseEvent.CLICK,closeFunc);
//mc.list_btn.addEventListener(MouseEvent.CLICK,showFunc);
//mc.sink_btn.addEventListener(MouseEvent.CLICK,showFunc);
add_btn.addEventListener(MouseEvent.CLICK,addFunc);
delete_btn.addEventListener(MouseEvent.CLICK,deleteFunc);
edit_btn.addEventListener(MouseEvent.CLICK,editFunc);

function addFunc(event:MouseEvent):void {
 edit_tool.visible=true;
 delete_tool.visible=false;
 edit_tool.gotoAndPlay(2);
 delete_tool.gotoAndStop(1);

}
function deleteFunc(event:MouseEvent):void {
 edit_tool.visible=false;
 delete_tool.visible=true;
 delete_tool.gotoAndPlay(2);
 edit_tool.gotoAndStop(1);
}
function editFunc(event:MouseEvent):void {
}
function closeFunc(event:MouseEvent) {
 for (var i=0; i<event.target.parent.members.length; i++) {
  event.target.parent.members[i].visible=false;
 }


}
/*function showFunc(event:MouseEvent) {
for(var i=0;i<event.target.parent.members.length;i++){
event.target.parent.members[i].visible=false
}

 

}*/ 

 

 

pacGOQO_PLAYER.as

kage {
 import flash.display.*;
 import flash.events.*;
 import flash.media.Sound;
 import flash.media.SoundChannel;
 import flash.media.SoundMixer;
 import flash.media.SoundTransform;
 import flash.net.URLRequest;
 import flash.display.MovieClip;
 import flash.utils.Timer;
 import flash.events.TimerEvent;
 import flash.utils.getTimer;
 import flash.display.Shape;
 import flash.utils.ByteArray;
 import flash.system.*;
 import fl.controls.List;

 

 public class GOQO_PLAYER extends Sprite {
  //波形BetyArray
  private var BArray_0:ByteArray=new ByteArray;// 44.1 KHz 采样
  private var BArray_1:ByteArray=new ByteArray;//22.05 KHz
  private var BArray_2:ByteArray=new ByteArray;//11.025 KHz KHz
  ///////////////////
  public var song:SoundChannel;//歌曲SoundChannel对象
  public var timer:Timer;//timer对象
  private var soundFactory:Sound;//声音对象
  public var sink:MovieClip;//播放器皮肤
  //
  public var push:Boolean=false;//暂停
  private var count:int=0;//暂停基数
  private var add_time=0;//拖拉延时时间
  private var songTime_1:Number=0;//播放暂停时间控制属性1
  private var songTime_2:Number=0;//播放暂停时间控制属性2//
  private var songTime_3:Number=0;//播放暂停时间控制属性3
  private var songTime_4:Number=0;//播放暂停时间控制属性4
  private var oldBytesLoaded:Number=0;//临时下载量
  //
  public var isBuffering:Boolean=true;
  //
  public var sound_list:Array=new Array;//歌曲列表
  public var url:String;//当前歌曲地址
  public var sid:int=0;//当前歌曲第id
  //
  public var state:String;// 状态提示
  public var progress:int;//下载进度
  public var length=0;
  //
  public var total_time:int;//当前歌曲总播放时间
  public var playTime:int=0;//当前歌曲播放时间毫秒数
  public var playTimeStr:String="";//当前播放时间字符
  public var stopTime:int=0;//纪录stop时的时间
  //
  public var timerStop:Boolean=false;
  public var unRun:Boolean=false;
  public var volume=0.5;//音量;
  public var nextSoundBool:Boolean=false;
  public var waveArray=[];
  private var ListObj:List;

  public function GOQO_PLAYER(link:String,mc:MovieClip,list:List) {
   ListObj=list;
   sink=mc;
   link != null?url=link:"";
   timer=new Timer(1);
   timer.addEventListener("timer",sound_poition);

   init(url);

   var EnterFrame$$:MovieClip=new MovieClip;
   EnterFrame$$.addEventListener(Event.ENTER_FRAME,EnterFrame_);
  }
  function recount(... res) {
   res[0] == undefined?add_time=playTime:add_time=res[0];
   songTime_1=getTimer();//初始化计数器
   songTime_4=songTime_3=songTime_2=0;//初始化计数器

  }
  //停止
  public function stop() {
   state='stop';
   song.stop();
   songTime_1=getTimer();//初始化计数器
   songTime_4=songTime_3=songTime_2=0;//初始化计数器
   song=soundFactory.play(0);
   count=0;
   songTime_4=songTime_3=songTime_2=0;
   playTime=0;
   attoPush();
  }
  //换歌
  public function changeSound(item) {
   if (sound_list.length > 0) {
    sid=item;
    if (soundFactory.bytesLoaded < soundFactory.bytesTotal) {
     soundFactory.close();
     state="full memory";
    }
    song.stop();
    init(sound_list[sid]);
   }
  }
  //下一首
  public function nextSound():void {
   if (sound_list.length > 0) {
    if (soundFactory.bytesLoaded < soundFactory.bytesTotal) {
     soundFactory.close();
     state="full memory";
    }
    song.stop();
    sid++;
    if (sid >= sound_list.length) {
     sid=0;
    }
    init(sound_list[sid]);
   }
  }
  //上一首
  public function prveSound():void {
   if (sound_list.length > 0) {
    if (soundFactory.bytesLoaded < soundFactory.bytesTotal) {
     soundFactory.close();
     state="full memory";
    }
    song.stop();
    sid--;
    if (sid < 0) {
     sid=sound_list.length - 1;
    }
    init(sound_list[sid]);
   }
  }
  //开始播放
  private function openHandler(event:Event):void {

   soundPoition();

  }
  //播放完切换下一首
  private function soundCompleteHandler(event:Event):void {
   if (sound_list.length > 0) {
    trace("next");
    sid++;
    if (sid >= sound_list.length) {
     sid=0;
    }
    nextSoundBool=true;
    init(sound_list[sid]);
   }

  }
  private function id3Handler(event:Event):void {

   //trace("id3Handler: " + event);

  }
  //下载错误处理
  private function ioErrorHandler(event:Event):void {

   if (sid < sound_list.length) {
    nextSound();
    ListObj.selectedIndex=sid;
    ListObj.scrollToSelected();
   }

  }
  function completeHandler(event:Event):void {

   length=total_time=event.target.length;
   trace("compt:"+total_time);
  }
  //下载进度
  private function progressHandler(event:ProgressEvent):void {

   var this_=event.currentTarget;

   if (this_.bytesLoaded <= this_.bytesTotal) {
    //下载进度
    progress=int(this_.bytesLoaded / this_.bytesTotal * 10000) / 100;

    if (! this_.isBuffering) {
     //当前歌总时间;

     length=int(event.target.length);

     total_time=int(this_.length / this_.bytesLoaded * this_.bytesTotal);
     trace(total_time+"==="+length);
     //sink.txt.text=("total_time::"+total_time);
    } else {

     //song.stop();
    }
   }
  }
  //暂停-继续
  public function attoPush() {

   ++count;
   if (count % 2 == 0) {
    //撤消暂停
    trace("StartTime:" + playTime);
    push=false;
    recount();
    song=soundFactory.play(playTime);
    song.addEventListener(Event.SOUND_COMPLETE,soundCompleteHandler);
    timer.start();
   } else {
    //暂停
    trace("PushTime:" + playTime);
    timer.stop();
    push=true;
    song.stop();
    //add_time=0
   }
  }
  //进度拖拉
  public function attoBar(time:Number) {
   if (playTime <= length * 1000) {
    if (time >= length * 1000) {
     time=length * 1000;
    }
    if (time > 0 && time < length * 1000) {
     //time单位毫秒
     song.stop();//停止声音
     timer.stop();//暂停timer
     count=0;//暂停计数初始化
     playTime=time;

     recount(time);
     song=soundFactory.play(time);
     song.addEventListener(Event.SOUND_COMPLETE,soundCompleteHandler);
     timer.start();
    }
   }
  }
  //新建
  public function create_new(link) {

   song.stop();
   if (soundFactory.bytesLoaded < soundFactory.bytesTotal) {
    soundFactory.close();
    state="full memory";
   }
   init(link);
   playTime=0;
  }
  //重启Timer
  public function soundPoition() {
   timer.start();
  }
  //设置音量
  private function SetVolume(volume:Number):void {
   var transform:SoundTransform=song.soundTransform;
   transform.volume=volume;
   song.soundTransform=transform;
  }
  public function counter() {
   if (! push) {
    songTime_2=getTimer() + add_time;
    songTime_2=songTime_2 - songTime_4;

   } else if (push) {
    songTime_3=getTimer();
    songTime_4=songTime_3 - songTime_2;
   }
   var soundTime=songTime_2 - songTime_1;
   soundTime <= 0?soundTime=0:soundTime=soundTime;
   return soundTime;
  }
  private function EnterFrame_(event:Event) {
   //音量

  }
  //Timer事件执行
  public function sound_poition(event:TimerEvent):void {
   SetVolume(volume);
   //波形.
   waveArray=showBar();
   //播放时间
   playTime=song.position;
   //playTime=counter();

   if (playTime <= length) {
    isBuffering=false;
    push=false;
   } else if (soundFactory.isBuffering) {
    //playTime=counter();
    playTime=song.position;
    isBuffering=true;
    push=true;
   }
   var msec=int(playTime) % 1000;
   var sece=int(playTime / 1000) % 60;
   var min=int(playTime / 1000 / 60);
   playTimeStr=min + ":" + sece + ":" + msec;
  }
  //获取对象列表
  private function getDisplayList(container:DisplayObjectContainer):Array {
   var returnArr:Array=new Array;
   var num:uint=container.numChildren;
   for (var i:uint; i < num; i++) {
    returnArr.push(container.getChildAt(i));
   }
   return returnArr;
  }

  //初始化
  private function init(link) {
   if (link!==null) {
    state="createNew";
    //bar_long=sink.mask_.width;
    recount();
    url=link;
    push=false;
    length=0;
    add_time=0;
    count=0;
    var request:URLRequest=new URLRequest(link);
    soundFactory=new Sound  ;
    soundFactory.addEventListener(Event.ID3,id3Handler);
    soundFactory.addEventListener(Event.COMPLETE, completeHandler);
    soundFactory.addEventListener(IOErrorEvent.IO_ERROR,ioErrorHandler);
    soundFactory.addEventListener(ProgressEvent.PROGRESS,progressHandler);
    soundFactory.addEventListener(Event.OPEN,openHandler);
    soundFactory.load(request);
    song=soundFactory.play(0);
    song.addEventListener(Event.SOUND_COMPLETE,soundCompleteHandler);

   }
  }
  //波形
  private function showBar() {
   if (song.soundTransform.volume > 0) {
    sink.Wave_mc.scaleX=0.25;

    SoundMixer.computeSpectrum(BArray_0,true,0);
    SoundMixer.computeSpectrum(BArray_1,true,1);
    SoundMixer.computeSpectrum(BArray_2,true,2);

    var arr=[BArray_0,BArray_1,BArray_2];
    var clo=[0xcc6699,0xffffff,0x339966];
    var result=[];
    sink.Wave_mc.graphics.clear();
    sink.Wave_mc.graphics.lineStyle(song.leftPeak * song.rightPeak,clo[0],100 * song.leftPeak * song.rightPeak);
    sink.Wave_mc.graphics.moveTo(0,0);
    for (var i=0; i < 512; i+= 10) {
     var arrb=[360 * arr[0].readFloat(),360 * arr[1].readFloat(),360 * arr[2].readFloat()];
     for (var j=0; j < arrb.length - 1; j++) {
      for (var k=j + 1; k < arrb.length; k++) {
       if (arrb[j] > arrb[k]) {
        var tmp=arrb[j];
        arrb[j]=arrb[k];
        arrb[k]=tmp;
       }
      }
     }
     result.push(arrb);
     sink.Wave_mc.graphics.lineTo(i,- arrb[0] / 5);
     sink.Wave_mc.graphics.lineTo(i,- arrb[arrb.length - 1] / 5);
     //sink.Wave_mc.graphics.lineStyle((song.leftPeak*song.rightPeak),clo[1],100*(song.leftPeak*song.rightPeak));
     //sink.Wave_mc.graphics.lineTo(i,100);

     //sink.Wave_mc.graphics.lineTo(i,100);
     //sink.Wave_mc.graphics.lineStyle((song.leftPeak*song.rightPeak),clo[2],100*(song.leftPeak*song.rightPeak));
     //sink.Wave_mc.graphics.moveTo(512+i,100);
     //sink.Wave_mc.graphics.lineTo(512+i,100-(360*arr[2].readFloat()/5));

    }
    return result;
   }
  }
 }
}

 

 

 Loader_Img.as

package {
 import flash.display.*;
 //import flash.display.Loader;
 //import flash.display.Sprite;
 import flash.events.*;
 import flash.net.URLRequest;
 import flash.display.MovieClip;
 import flash.utils.Timer;
 import flash.events.TimerEvent;
 import flash.utils.getTimer;
 import fl.controls.List;
 import flash.system.fscommand;
 import GOQO_PLAYER;


 public class Loader_Img extends Sprite {
  private var url:String;
  private var target:MovieClip;
  private var loader:Loader;
  private var loader2:Loader;
  public var goqoSound:GOQO_PLAYER;
  public var sound_list:Array;
  private var Sink:MovieClip;
  private var VolumeCount:Number=0;
  private var TmpVolume:Number=0.5;
  private var VolumeBool:Boolean=true;
  public var MoveBool:Boolean=false;
  private var mouse_down:Boolean=false;
  public var SetProgressTime:Number=0;
  public var ErrState:String;
  public var state:String="";
  public var count:Number=0;
  public var ListObj:List;
  public var WaveArray=[];
  public var BarX:Number;
  private var changeBool:Boolean=false;
  public function Loader_Img(link:String,tar:MovieClip,soundList:Array,obj:List) {
   ListObj=obj;
   ListObj.selectedIndex=0;
   sound_list=soundList;
   target=tar;
   url=link;
   loader=new Loader () ;
   ConfigureListeners(loader.contentLoaderInfo);
   var request:URLRequest=new URLRequest(url);
   loader.load(request);

  }

  private function ConfigureListeners(dispatcher:IEventDispatcher):void {

   dispatcher.addEventListener(Event.COMPLETE,DownLoad_Complete);
   //dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
   //dispatcher.addEventListener(Event.INIT, initHandler);
   //dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
   //dispatcher.addEventListener(Event.OPEN, openHandler);
   //dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
   //dispatcher.addEventListener(Event.UNLOAD, unLoadHandler);
  }
  public function PlaySelected(id:int,list:Array) {
   sound_list=list;

   goqoSound.sound_list=list;
   goqoSound.changeSound(id);
  }
  public function UpdataList(list:Array) {
   sound_list=list;
   goqoSound.sound_list=list;

  }
  public function removeAll() {
   goqoSound.stop();
   sound_list=[];
   ListObj.removeAll();
   goqoSound.sound_list=[];
   goqoSound.song=null;
   //goqoSound.timer.stop()
  }
  public function ChangSink(link) {
   changeBool=true;
   loader2=new Loader ;
   var request2:URLRequest=new URLRequest(link);
   loader2.load(request2);
   loader2.contentLoaderInfo.addEventListener(Event.COMPLETE,DownLoad_Complete_Sink);
   //target.addChildAt(loader2);

  }
  private function DownLoad_Complete_Sink(event:Event):void {

   target.removeChildAt(0);
   target.addChildAt(loader2,0);
   Sink=event.target.content;
   Sink.Volume_bar.mask_mc.scaleX=TmpVolume;
   //ListObj.y=Sink.height+10
   if (VolumeCount % 2 == 1) {
    Sink.Volume_btn.gotoAndStop(2);
    goqoSound.volume=0;
    VolumeBool=false;


   } else if (VolumeCount % 2 == 0) {
    Sink.Volume_btn.gotoAndStop(1);
    goqoSound.volume=TmpVolume;
    VolumeBool=true;

   }
   goqoSound.sink=Sink;
   Sink.addEventListener(MouseEvent.MOUSE_DOWN,GetMouseDown);
   Sink.addEventListener(MouseEvent.MOUSE_UP,GetMouseUp);
   Sink.addEventListener(Event.ENTER_FRAME,EnterFrame);
   Sink.parent.addEventListener(MouseEvent.MOUSE_MOVE,MouseMove);
   event.target.content.List_btn.members=target.list_member_arr;
   event.target.content.Sink_btn.members=target.sink_member_arr
   ;
   event.target.content.List_btn.addEventListener(MouseEvent.CLICK,Show_Func);
   event.target.content.Sink_btn.addEventListener(MouseEvent.CLICK,Show_Func);
   event.target.content.Play_btn.addEventListener(MouseEvent.CLICK,Play_Func);
   event.target.content.Stop_btn.addEventListener(MouseEvent.CLICK,Stop_Func);
   event.target.content.Prve_btn.addEventListener(MouseEvent.CLICK,Prve_Func);
   event.target.content.Next_btn.addEventListener(MouseEvent.CLICK,Next_Func);
   event.target.content.Volume_btn.addEventListener(MouseEvent.CLICK,Volume_Funcx);

   BarX=Sink.Bar_btn.x;
  }
  private function Show_Func(event:Event):void {

   for (var iv=0; iv<event.target.members.length; iv++) {
    if (!event.target.members[iv].visible) {
     event.target.members[iv].visible=true;
    } else {
     event.target.members[iv].visible=false;
    }
   }
  }
  private function DownLoad_Complete(event:Event):void {

   target.addChildAt(loader,0);
   var loader_info=loader.contentLoaderInfo;

   goqoSound=new GOQO_PLAYER(sound_list[0],event.target.content,ListObj);
   goqoSound.sound_list=sound_list;

   Sink=event.target.content;
   Sink.addEventListener(MouseEvent.MOUSE_DOWN,GetMouseDown);
   Sink.addEventListener(MouseEvent.MOUSE_UP,GetMouseUp);
   Sink.parent.addEventListener(MouseEvent.MOUSE_MOVE,MouseMove);
   
   Sink.addEventListener(Event.ENTER_FRAME,EnterFrame);
   event.target.content.List_btn.members=target.list_member_arr;
   event.target.content.Sink_btn.members=target.sink_member_arr;

   event.target.content.List_btn.addEventListener(MouseEvent.CLICK,Show_Func);
   event.target.content.Sink_btn.addEventListener(MouseEvent.CLICK,Show_Func);
   event.target.content.Play_btn.addEventListener(MouseEvent.CLICK,Play_Func);
   event.target.content.Stop_btn.addEventListener(MouseEvent.CLICK,Stop_Func);
   event.target.content.Prve_btn.addEventListener(MouseEvent.CLICK,Prve_Func);
   event.target.content.Next_btn.addEventListener(MouseEvent.CLICK,Next_Func);

   event.target.content.Volume_btn.addEventListener(MouseEvent.CLICK,Volume_Funcx);

   BarX=Sink.Bar_btn.x;
  }
  
  private function MouseMove(event:MouseEvent):void {
   if(!MoveBool&&mouse_down){
   trace("--");
   
   fscommand("MoveWindow", "");
   }
   }
  private function Play_Func(event:MouseEvent):void {
   MoveBool=false;
   goqoSound.attoPush();
   trace("StartPlay::" + goqoSound.state);
  }

  private function Stop_Func(event:MouseEvent):void {
   MoveBool=false;
   goqoSound.stop();
   trace("StartPlay::" + goqoSound.state);
  }

  private function Prve_Func(event:MouseEvent):void {
   trace("Prve::");
   MoveBool=false;
   goqoSound.prveSound();

   ListObj.selectedIndex=goqoSound.sid;
   ListObj.scrollToSelected();
  }

  private function Next_Func(event:MouseEvent):void {
   trace("Next::");
   MoveBool=false;
   goqoSound.nextSound();
   ListObj.selectedIndex=goqoSound.sid;
   ListObj.scrollToSelected();
  }

  private function Volume_Funcx(event:MouseEvent):void {
   trace(VolumeBool+"====");
   MoveBool=false;
   if (VolumeBool) {
    Sink.Volume_btn.gotoAndStop(2);
    goqoSound.volume=0;
    VolumeBool=false;
    trace("SetVolume::0");

   } else if (!VolumeBool) {
    Sink.Volume_btn.gotoAndStop(1);
    goqoSound.volume=TmpVolume;
    VolumeBool=true;
    trace("SetVolume::" + TmpVolume);
   }
  }
  private function Set_Volume() {

   if (mouse_down && VolumeBool) {

    if (Sink.Volume_bar.hitTestPoint(mouseX,mouseY,false)) {
     MoveBool=false;
     var volume=Sink.Volume_bar.mouseX / 30;
     TmpVolume=volume;
     Sink.Volume_bar.mask_mc.scaleX=volume;
     if (volume < 0) {
      volume=0;
     }
     goqoSound.volume=Sink.Volume_bar.mask_mc.scaleX;
    }
   }
  }
  private function MoveBar() {

   if (Sink.Bar_btn.hitTestPoint(mouseX,mouseY,false)) {
    MoveBool=true;

   }
   if (mouse_down && MoveBool) {
    if (mouseX - Sink.Bar_tool.x>=0&&(Sink.Bar_btn.x -BarX) < Sink.Bar_tool.width * goqoSound.progress / 100) {
     Sink.Bar_btn.x=Sink.mouseX+Sink.Bar_btn.width-2;
     if (Sink.Bar_btn.x<BarX) {
      Sink.Bar_btn.x=BarX;
     }
     if (Sink.Bar_btn.x>Sink.Bar_tool.width+BarX) {
      Sink.Bar_btn.x=Sink.Bar_tool.width+BarX;
     }
     SetProgressTime=goqoSound.total_time * (Sink.Bar_btn.x -BarX) / Sink.Bar_tool.width;

    }
   } else {
    if (!goqoSound.isBuffering) {

     Sink.Bar_btn.x=goqoSound.playTime / goqoSound.total_time * Sink.Bar_tool.width + BarX+Sink.Bar_btn.width/2;
    } else {


    }
   }
  }
  private function EnterFrame(event:Event) {

   //trace("下载::" + Sink.Bar_tool.mask_.width);
   if (mouse_down&&MoveBool&&!Sink.hitTestPoint(mouseX,mouseY,false)) {
    MoveBool=false;
    goqoSound.attoBar(int(SetProgressTime));
   }
   //trace(Sink.Bar_btn)
   var hitBlo_1=Sink.hitTestPoint(mouseX,mouseY,false);
   var hitBlo_2=Sink.Play_btn.hitTestPoint(mouseX,mouseY,false);
   var hitBlo_3=Sink.Bar_btn.hitTestPoint(mouseX,mouseY,false);
   var hitBlo_4=Sink.Bar_tool.hitTestPoint(mouseX,mouseY,false);
   
   //if (mouse_down&&!MoveBool&&hitBlo_1 &&!hitBlo_2&&!hitBlo_3&&!hitBlo_4) {

//trace( hitBlo_1, hitBlo_2, hitBlo_3, hitBlo_4);
   

   //}
   Sink.Time_txt.text=goqoSound.playTimeStr;
   Sink.Bar_tool.mask_.scaleX=goqoSound.progress / 100;
   Set_Volume();
   MoveBar();
   WaveArray=goqoSound.waveArray;
   if (goqoSound.nextSoundBool) {

    ListObj.selectedIndex=goqoSound.sid;
    ListObj.scrollToSelected();
    goqoSound.nextSoundBool=false;
    //trace(goqoSound.sid+"===ddd++++++++++++++++===");
   }
  }
  private function GetMouseDown(event:MouseEvent):void {

   mouse_down=true;
   if (Sink.Volume_bar.hitTestPoint(mouseX,mouseY,false)) {
    VolumeBool=true;
   }
  }
  private function GetMouseUp(event:MouseEvent):void {
   //trace(Sink.hitTestPoint(mouseX,mouseY,false)+"---+++");
   //trace(Sink.Volume_btn.hitTestPoint(mouseX,mouseY,false)+"---");
   if (MoveBool&&!Sink.Volume_btn.hitTestPoint(mouseX,mouseY,false)) {

    goqoSound.attoBar(int(SetProgressTime));
   }
   if (!Sink.Volume_btn.hitTestPoint(mouseX,mouseY,false)&&!Sink.Volume_bar.hitTestPoint(mouseX,mouseY,false)) {
    VolumeBool=false;
   }
   mouse_down=false;
   MoveBool=false;
   if (!goqoSound.isBuffering) {

    Sink.Bar_btn.x=goqoSound.playTime / goqoSound.total_time * Sink.Bar_tool.width + Sink.Bar_tool.x+Sink.Bar_btn.width/2;
   }
  }
  /*private function httpStatusHandler(event:HTTPStatusEvent):void {
  trace("httpStatusHandler: " + event);
  }
  
  private function initHandler(event:Event):void {
  trace("initHandler: " + event);
  }
  
  private function ioErrorHandler(event:IOErrorEvent):void {
  trace("ioErrorHandler: " + event);
  }
  
  private function openHandler(event:Event):void {
  trace("openHandler: " + event);
  }
  
  private function progressHandler(event:ProgressEvent):void {
  trace("progressHandler: bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
  }
  
  private function unLoadHandler(event:Event):void {
  //trace("unLoadHandler: " + event);
  }*/
 }
}

 

上一篇:{教程}as 3.0 事件 声明 人气:5319
下一篇:{教程}有关AS3编程的一些总结 人气:4586
视频教程列表
文章教程搜索
 
Flash AS推荐教程
Flash AS热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058