18-10-2006, 20:45
|
|
|
|
חבר מתאריך: 07.12.05
הודעות: 61
|
|
רשימת שירים, יש לי קוד שקורא מ-xml
מערך של שירים ומעביר בכל לחיצה על אותו כפתור, לשיר הבא. איך אני משנה כך שיהיו לי מספר כפתורים, כפתור לכל שיר, וכל כפתור ינגן שיר אחר.
זה הקוד שקורא ל- xml
קוד:
var singAsong = new Array
var playAsong = new Sound
var now_playing = 0
var song_volume = 75
function play_list_loaded() {
for (i=0; i<play_list.firstChild.childNodes.length; i++) {
singAsong[i] = {song_URL : play_list.firstChild.childNodes[i].childNodes[1].childNodes[0].nodeValue, song_title : play_list.firstChild.childNodes[i].childNodes[0].childNodes[0].nodeValue}
trace(singAsong[i].song_URL)
}
random_song = Math.floor(Math.random()*singAsong.length)
playAsong.loadSound( singAsong[random_song].song_URL, true);
playAsong.setVolume(75)
}
function next_t() {
now_playing ++
if (now_playing > singAsong.length - 1) {
now_playing = 0;}
playAsong.loadSound( singAsong[now_playing].song_URL, true);
playAsong.setVolume(song_volume);
}
function prev_t() {
now_playing --
if (now_playing < 0) {
now_playing = singAsong.length - 1
}
playAsong.loadSound( singAsong[now_playing].song_URL, true)
playAsong.setVolume(song_volume)
}
function graphic_EQ() {
random_bet = Math.random()*100
for (i=1 ; i < 5 ; i ++) {
_root["a"+i]._visible = _root["b"+i]._visible = random_bet > 20 * i
}
}
var play_list = new XML();
play_list.ignoreWhite = true;
play_list.onLoad = play_list_loaded;
play_list.load("music/play_list.XML");
playAsong.onSoundComplete = function() {next_t()} ;
next_track.onRelease = function() {next_t()} ;
prev_track.onRelease = function() {prev_t()} ;
_root.onEnterFrame = graphic_EQ;
|