我想玩數組中的隨機聲音。這是我正在使用的代碼。有任何想法嗎?這是行不通的。as3 URLRequest聲音存儲在數組中?
import flash.media.Sound;
//var mySound:Sound = new Sound();
var mySoundsArray:Array = ["blue.mp3","green.mp3","red.mp3","yellow.mp3"];
var storedSounds:Array;
for(var i =0; i < mySoundsArray.length; i++)
{
/// DOES NOT WORK BELOW
storedSounds[i] = new Sound();
storedSounds[i].load(new URLRequest("sounds/" + mySoundsArray[i]));
}
/// later to loop through sounds but for now I use the line below default at 0
mySoundsArray[0].play();
工作得很好'這不是working'出現任何錯誤? – Kolyunya 2012-08-16 07:54:38
TypeError:錯誤#1009:無法訪問空對象引用的屬性或方法。 \t at test_fla :: MainTimeline/frame1() – 2012-08-16 08:02:02
很確定問題在於這一行 - - storedSounds [i] = new Sound(); – 2012-08-16 08:02:39