Re: [問題] 請問動態寫法
※ 引述《ginnz (go)》之銘言:
: 如何使用迴圈宣告以下內容? 感謝!
: var music1:Sound;
: music1=new Sound();
: var path1:URLRequest=new URLRequest("sample_1.mp3");
: music1.load(path1);
: var music2:Sound;
: music2=new Sound();
: var path2:URLRequest=new URLRequest("sample_2.mp3");
: music2.load(path2);
: var music3:Sound;
: music3=new Sound();
: var path3:URLRequest=new URLRequest("sample_3.mp3");
: music3.load(path3);
: var music4:Sound;
: music4=new Sound();
: var path4:URLRequest=new URLRequest("sample_4.mp3");
: music4.load(path4);
var music:Array = new Array();
for(var i = 1 ; i <= 4 ; i++)
{
music[i] = new Sound();
music[i].load(new URLRequest("sample_"+i+".mp3"));
}
這樣應該可以吧 ?
--
blog:http://etrex.blogspot.com/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.167.8.251
推
05/17 20:26, , 1F
05/17 20:26, 1F
討論串 (同標題文章)