2012-11-19 85 views

回答

0
var mySound:Sound = new Sound(); 
var myChannel:SoundChannel = new SoundChannel(); 

music_on_btn.addEventListener(MouseEvent.CLICK, onClickStart); 
music_off_btn.addEventListener(MouseEvent.CLICK, onClickStop); 


function onClickStart(e:MouseEvent):void 
{ 
mySound.load(new URLRequest("myFavSong.mp3")); 
myChannel = mySound.play(); 
} 

function onClickStop(e:MouseEvent):void 
{ 
myChannel.stop(); 
} 

更多的查询,你也可以去通过这些链接, http://www.republicofcode.com/tutorials/flash/as3sound/ http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html

希望它可以帮助...

0
var mySound:Sound = new Sound(); 
var myChannel:SoundChannel = new SoundChannel(); 
var lastPosition:Number = 0; 
mySound.load(new URLRequest("mysong.mp3")); 
myChannel = mySound.play(); 

pause_btn.addEventListener(MouseEvent.CLICK, onClickPause); 

function onClickPause(e:MouseEvent):void{ 
lastPosition = myChannel.position; 
myChannel.stop(); 
} 

play_btn.addEventListener(MouseEvent.CLICK, onClickPlay); 

function onClickPlay(e:MouseEvent):void{ 
myChannel = mySound.play(lastPosition); 
}