flash as3.0 怎么实现两首歌曲分别点击两个按钮开始播放,再点击点击暂停 ,不用影片剪辑的方法
展开全部
private var snd:Sound = new Sound();
private var channel:SoundChannel = new SoundChannel();
private var button:TextField = new TextField();
public function SoundChannel_stopExample() {
var req:URLRequest = new URLRequest("MySound.mp3");
snd.load(req);
//你可以用你自己的Button,这里直接弄了一个textField
button.x = 10;
button.y = 10;
button.text = "PLAY";
button.border = true;
button.background = true;
button.selectable = false;
button.autoSize = TextFieldAutoSize.CENTER;
button.addEventListener(MouseEvent.CLICK, clickHandler);
this.addChild(button);
}
private function clickHandler(e:MouseEvent):void {
var pausePosition:int = channel.position;
if(button.text == "PLAY") {
channel = snd.play(pausePosition);
button.text = "PAUSE";
}
else {
channel.stop();
button.text = "PLAY";
}
}
private var channel:SoundChannel = new SoundChannel();
private var button:TextField = new TextField();
public function SoundChannel_stopExample() {
var req:URLRequest = new URLRequest("MySound.mp3");
snd.load(req);
//你可以用你自己的Button,这里直接弄了一个textField
button.x = 10;
button.y = 10;
button.text = "PLAY";
button.border = true;
button.background = true;
button.selectable = false;
button.autoSize = TextFieldAutoSize.CENTER;
button.addEventListener(MouseEvent.CLICK, clickHandler);
this.addChild(button);
}
private function clickHandler(e:MouseEvent):void {
var pausePosition:int = channel.position;
if(button.text == "PLAY") {
channel = snd.play(pausePosition);
button.text = "PAUSE";
}
else {
channel.stop();
button.text = "PLAY";
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询