Frame 1
function button_stop_tone(ent) {
}
function button_play_test(ent) {
xp = (ent._xmouse + ent._x) - ent._xfix;
yp = (ent._ymouse + ent._y) - ent._yfix;
if ((Math.abs(xp) < finger_radius) && (Math.abs(yp) < finger_radius)) {
if (Math.sqrt((xp * xp) + (yp * yp)) < finger_radius) {
ent.pressed = true;
} else {
ent.pressed = false;
}
} else {
ent.pressed = false;
}
if (ent.pressed) {
if (ent.mouse_down) {
ent.pressed = 2;
ent._x = ent._xfix + 2;
ent._y = ent._yfix + 2;
if (!ent.prev_pressed) {
pressSound.start(0.025);
}
} else {
ent._x = ent._xfix - 2;
ent._y = ent._yfix - 2;
}
soundz[ent.note].button_requests = soundz[ent.note].button_requests + 1;
} else {
ent._x = ent._xfix;
ent._y = ent._yfix;
soundz[ent.note].button_requests = soundz[ent.note].button_requests - 1;
}
if ((ent.pressed && (!ent.prev_pressed)) && (ent.mouse_down)) {
soundz[ent.note].sound.start(0.025);
}
if ((!ent.pressed) || (!ent.mouse_down)) {
button_stop_tone(ent);
if (ent.prev_pressed == 2) {
releaseSound.start(0.025);
}
}
}
soundz = new Array();
pressSound = new Sound();
pressSound.attachSound("press");
releaseSound = new Sound();
releaseSound.attachSound("release");
s = 0;
while (s < 12) {
soundz[s] = new Object();
soundz[s].button_requests = 0;
soundz[s].sound = new Sound();
switch (s) {
case 9 :
soundz[s].soundname = "_A";
break;
case 10 :
soundz[s].soundname = "_As";
break;
case 11 :
soundz[s].soundname = "_B";
break;
case 0 :
soundz[s].soundname = "_C";
break;
case 1 :
soundz[s].soundname = "_Cs";
break;
case 2 :
soundz[s].soundname = "_D";
break;
case 3 :
soundz[s].soundname = "_Ds";
break;
case 4 :
soundz[s].soundname = "_E";
break;
case 5 :
soundz[s].soundname = "_F";
break;
case 6 :
soundz[s].soundname = "_Fs";
break;
case 7 :
soundz[s].soundname = "_G";
break;
case 8 :
soundz[s].soundname = "_Gs";
}
soundz[s].sound.attachSound(soundz[s].soundname);
s++;
}
num_down = 10;
num_across = 20;
buttonz = new Array();
top_note = 10000;
index = 0;
finger_radius = 22;
tl = 3;
tr = 7 - tl;
up = tr + tl;
y = 0;
while (y < num_across) {
switch (y % 2) {
case 0 :
top_note = top_note + tr;
break;
case 1 :
top_note = top_note - tl;
}
x = 0;
while (x < num_down) {
attachMovie("Hexagon", "Hexagon" + index, index);
buttonz[index] = eval ("Hexagon" + index);
buttonz[index].note = (top_note - (up * x)) % 12;
buttonz[index].gotoAndStop((buttonz[index].note % 12) + 1);
buttonz[index]._x = (y * 26.9) + 50;
buttonz[index]._y = ((x * 31.2) + 50) + (((y % 2) * 31.2) / 2);
buttonz[index]._xfix = buttonz[index]._x;
buttonz[index]._yfix = buttonz[index]._y;
buttonz[index].onMouseDown = function () {
this.mouse_down = true;
this.prev_pressed = false;
button_play_test(this);
};
buttonz[index].onMouseUp = function () {
this.prev_pressed = this.pressed;
this.mouse_down = false;
this.pressed = false;
button_play_test(this);
};
buttonz[index].onMouseMove = function () {
this.prev_pressed = this.pressed;
button_play_test(this);
};
index++;
x++;
}
y++;
}