我是 Actionscript 3 和使用 Flash CS6 的新手。
-我正在尝试播放/暂停名为 countrymeadow 的 20 分钟 mp3
-countrymeadow.mp3 链接到库中的 Export for actionscript (countrymeadow)。
playpause mc 按钮在按钮内的第 1 帧(播放)和第 10 帧(暂停)停止。
AS3 在下面,但它不起作用,因为 mc 播放暂停按钮在测试时不断在“播放”和“暂停”之间切换,而且没有播放声音。
任何帮助表示赞赏,并提前非常感谢。
//set appearance of button, mode to true
playpause_mc.gotoAndStop("play");
playpause_mc.buttonMode = true;
//sound is stopped after loaded
var isPaused:Boolean = true;
//saves current position of sound
var currPos:int = 0.00;
var theSound:countrymeadow = new countrymeadow();
snd.play();
var soundCnl:SoundChannel = new SoundChannel();
//Listener updates after sound loads, and stops soundtheSound.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
function onComplete(evt:Event):void {
//Stop loaded sound
soundCnl.stop();
}
// movie clip button control
playpause_mc.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void {
if(isPaused){
//change state to playing, and play sound from position
isPaused = false;
soundCnl = theSound.play(currPos);
//reverse the appearance of the button
playpause_mc.gotoAndStop("pause")
//if sound completes while playing, run function
soundCnl.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
}else{
//it's playing, so save position and pause sound
currPos = soundCnl.position;
isPaused = true;
soundCnl.stop();
//change the appearance of the buttons
playpause_mc.gotoAndStop("play")
}
}