// In this example only the QWERT and Arrows are working
// importing the following sounds in the same folder
// as the swf file
// sound_37.mp3 = Left
// sound_38.mp3 = Up
// sound_39.mp3 = Right
// sound_40.mp3 = Down
// sound_69.mp3 = E
// sound_81.mp3 = Q
// sound_82.mp3 = R
// sound_84.mp3 = T
// sound_87.mp3 = W
// You would have to create a sound for each key
// The SPACE bar stops all sounds
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.media.SoundTransform;
var myChannel:SoundChannel = new SoundChannel();
var myTransform = new SoundTransform();
myTransform.volume = 0.9;// SET THE VOLUME
myChannel.soundTransform = myTransform;// TRANSFORM VOLUME
//////////////////
stage.addEventListener(KeyboardEvent.KEY_DOWN, downKey);
function downKey(event:KeyboardEvent) {
DISPLAY.text = event.keyCode.toString() + " // " + String.fromCharCode(event.charCode)
switch (event.keyCode) {
case 65 :
playSound(65);
break;
case 66 :
playSound(66);
break;
case 67 :
playSound(67);
break;
case 68 :
playSound(68);
break;
case 69 :
playSound(69);
break;
case 70 :
playSound(70);
break;
case 71 :
playSound(71);
break;
case 72 :
playSound(72);
break;
case 73 :
playSound(73);
break;
case 74 :
playSound(74);
break;
case 75 :
playSound(75);
break;
case 76 :
playSound(76);
break;
case 77 :
playSound(77);
break;
case 78 :
playSound(78);
break;
case 79 :
playSound(79);
break;
case 80 :
playSound(80);
break;
case 81 :
playSound(81);
break;
case 82 :
playSound(82);
break;
case 83 :
playSound(83);
break;
case 84 :
playSound(84);
break;
case 85 :
playSound(85);
break;
case 86 :
playSound(86);
break;
case 87 :
playSound(87);
break;
case 88 :
playSound(88);
break;
case 89 :
playSound(89);
break;
case 90 :
playSound(90);
break;
case 49 :
playSound(49);
break;
case 50 :
playSound(50);
break;
case 51 :
playSound(51);
break;
case 52 :
playSound(52);
break;
case 53 :
playSound(53);
break;
case 54 :
playSound(54);
break;
case 55 :
playSound(55);
break;
case 56 :
playSound(56);
break;
case 57 :
playSound(57);
break;
case 186 :
playSound(186);
break;
case 187 :
playSound(187);
break;
case 188 :
playSound(188);
break;
case 189 :
playSound(189);
break;
case 190 :
playSound(190);
break;
case 191 :
playSound(191);
break;
case 192 :
playSound(192);
break;
case 219 :
playSound(219);
break;
case 220 :
playSound(220);
break;
case 221 :
playSound(221);
break;
case 222 :
playSound(222);
break;
case 96 :
playSound(96);
break;
case 97 :
playSound(97);
break;
case 98 :
playSound(98);
break;
case 99 :
playSound(99);
break;
case 100 :
playSound(100);
break;
case 101 :
playSound(101);
break;
case 102 :
playSound(102);
break;
case 103 :
playSound(103);
break;
case 104 :
playSound(104);
break;
case 105 :
playSound(105);
break;
case 106 :
playSound(106);
break;
case 107 :
playSound(107);
break;
case 109 :
playSound(109);
break;
case 110 :
playSound(110);
break;
case 111 :
playSound(111);
break;
case 13 :
playSound(13);
break;
case 112 :
playSound(112);
break;
case 113 :
playSound(113);
break;
case 114 :
playSound(114);
break;
case 115 :
playSound(115);
break;
case 116 :
playSound(116);
break;
case 117 :
playSound(117);
break;
case 118 :
playSound(118);
break;
case 119 :
playSound(119);
break;
case 120 :
playSound(120);
break;
case 121 :
playSound(121);
break;
case 122 :
playSound(122);
break;
case 123 :
playSound(123);
break;
case 124 :
playSound(124);
break;
case 125 :
playSound(125);
break;
case 126 :
playSound(126);
break;
case 37 :
playSound(37);
break;
case 38 :
playSound(38);
break;
case 39 :
playSound(39);
break;
case 40 :
playSound(40);
break;
case 19 :
playSound(19);
break;
case 33 :
playSound(33);
break;
case 34 :
playSound(34);
break;
case 35 :
playSound(35);
break;
case 36 :
playSound(36);
break;
case 45 :
playSound(45);
break;
case 46 :
playSound(46);
break;
case 145 :
playSound(145);
break;
case 8 :
playSound(8);
break;
case 16 :
playSound(16);
break;
case 17 :
playSound(17);
break;
case 18 :
playSound(18);
break;
case 27 :
playSound(27);
break;
case 32 :
playSound(32);
}
}
////////
var id:uint;
function playSound(id) {
var newSong:String = "sound_" + id + ".mp3";
if (id == 32) {
myChannel.stop();
} else {
myChannel.stop();
var mySound:Sound = new Sound();
mySound.load(new URLRequest(newSong));
myChannel = mySound.play(); // PLAY NEW SONG
}
}