soundManager.url = './swf' soundManager.debugMode = false; soundManager.onload = function() { for (var i = 0; i < seq_rows; i++) soundManager.createSound({ id: 'snd'+i , url: 'snd/'+i+'.mp3', }); }; var seq_rows = 16; var seq_cols = 16; var seq_width = 32; var seq_height = 32; var seq_space = 4; var seq_pos = -1; var locol_a = '#f60'; var hicol_a = '#f00'; var locol = '#888'; var hicol = '#444' var seq_handles; function seqService() { seq_pos++; seq_pos %= seq_cols; for (var i = 0; i < seq_rows; i++) { var btnid = (i * seq_cols + seq_pos); if (seq_handles[btnid].s_state) { seq_handles[btnid].style.backgroundColor = hicol_a; soundManager.play('snd'+seq_handles[btnid].s_y); } else seq_handles[btnid].style.backgroundColor = hicol; btnid = (btnid % seq_cols) ? (btnid - 1) : (btnid + seq_cols - 1); seq_handles[btnid].style.backgroundColor = seq_handles[btnid].s_state ? locol_a : locol; } } function flip(that) { that.s_state = !that.s_state; if (that.s_x == seq_pos) that.style.backgroundColor = that.s_state ? hicol_a : hicol; else that.style.backgroundColor = that.s_state ? locol_a : locol; } function init() { var divtpl = document.createElement('div'); divtpl.setAttribute('name', 'btn'); divtpl.setAttribute('onclick', 'flip(this)'); divtpl.style.width = seq_width + 'px'; divtpl.style.height = seq_height + 'px'; for (i = 0; i < seq_rows * seq_cols; i++) document.body.appendChild(divtpl.cloneNode(true)); seq_handles = document.getElementsByName("btn"); for (i = 0; i < seq_rows * seq_cols; i++) { seq_handles[i].s_state = false; seq_handles[i].s_x = i % seq_cols; seq_handles[i].s_y = Math.floor(i / seq_cols); seq_handles[i].s_i = i seq_handles[i].style.left = (seq_handles[i].s_x * (seq_width + seq_space) + seq_space) + 'px'; seq_handles[i].style.top = (seq_handles[i].s_y * (seq_height + seq_space) + seq_space) + 'px'; } setInterval('seqService()', 256); }