[RESOLVED] Play sound on keydown with timer
Hey! :-)
I would like to play a sound when a key is pressed, but then wait a second before playing the sound again. I've fiddled around with if (timer == 0), do the code, however anything I've tried hasn't worked.
I'm using the ActionScript 2 shown below:
Actionscript Code:
var sounds:Array = ["laser1","laser2"];//the identifiers
var n:Number=sounds.length;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if ((Key.isDown(16)))
{
_root.mySound = new Sound();
_root.mySound.attachSound(sounds[random(_root.n)]);
_root.mySound.start();
}
else if ((Key.isDown(32)))
{
_root.mySound = new Sound();
_root.mySound.attachSound(sounds[random(_root.n)]);
_root.mySound.start();
}
}
;
Key.addListener(keyListener);
I am both new to Flash and the Flashkit board, so if I haven't provided all the information you need, please tell me so! :)
Many thanks in advance,
Hellomynameis99