Does anyone know script for doing this?
I’m trying to play a sound on a space bar press.
I am using Flash MX
please help
thanks
Does anyone know script for doing this?
I’m trying to play a sound on a space bar press.
I am using Flash MX
please help
thanks
//Define Sound object
var my_sound = new Sound(this);
//Attach sound symbol from the Library (don't forget to export it for ActionScript)
my_sound.attachSound("id");
//Execute the code whenever a key is pressed
my_sound.onKeyDown = function() {
//Check if the spacebar has been pressed
if (Key.getCode() == 32) {
//Play the sound
this.start();
}
};
//Add the Sound object to the Key object listeners
Key.addListener(my_sound);
thank you very much … helped a whole lot
No problem, sinner.