我有2個按鈕在我的AS3項目加載.mp3文件,然後播放它們。我有兩個按鈕可以在那些不工作的文件之間切換。我得到一個錯誤說:AS3 - 2037錯誤
Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
at flash.media::Sound/_load()
at flash.media::Sound/load()
at player_fla::MainTimeline/playMusic1()
我在想這意味着該文件未加載之前,它試圖播放,是嗎?如何在播放前檢查文件是否已加載?
這裏是我的代碼:在Flash
function playMusic1(evt:MouseEvent):void{
channel.stop();
channel2.stop();
songPosition = 0;
var soundFile2:URLRequest = new URLRequest("http://r.jaxna.com/mp3Player/slushy.mp3");
myMusic2.load(soundFile2, myContext);
channel = myMusic.play(songPosition);
channel2 = myMusic2.play(songPosition);
}
function playMusic2(evt:MouseEvent):void {
channel.stop();
channel2.stop();
songPosition = 0;
var soundFile3:URLRequest = new URLRequest("http://r.jaxna.com/mp3Player/kingRight.mp3");
myMusic2.load(soundFile3, myContext);
channel = myMusic.play(songPosition);
channel2 = myMusic2.play(channel.position);