How do I get sound to activate with a key press? I can get objects to move around the screen. But I want a sound to happen when I press a key. And would I import the sound?
Printable View
How do I get sound to activate with a key press? I can get objects to move around the screen. But I want a sound to happen when I press a key. And would I import the sound?
Do in this way:
1)Create an empty movie clip with 4 keyframes named "snd"
2)Insert STOP for keyframes 2 and 4
3)Add the desired sound on keyframe 3
4)In the main timeline add this script:
if(Key.isDown(what you need)) {_root.snd.gotoAndPlay(3);}
that's all !
;)
I can not get this to workQuote:
Originally posted by necromanthus
Do in this way:
1)Create an empty movie clip with 4 keyframes named "snd"
2)Insert STOP for keyframes 2 and 4
3)Add the desired sound on keyframe 3
4)In the main timeline add this script:
if(Key.isDown(what you need)) {_root.snd.gotoAndPlay(3);}
that's all !
;)
I create a new movie clip. then create 4 keyframes. in frame 3 i added sound and used stop movie for 2 and 4.
in the main movie I went to sound and actions and added
if(Key.isDown(key.SPACE)) {_root.snd.gotoAndPlay(3);}
In the main movie i changed the mc name to snd.
any suggestions?
Thank you.
Just a thought - I had a problem with keyboard stuff, until Hilary advised me to first click in the movie (to give it focus). Thereafter it knows the keys are for it (or at least until you click outside the movie and transfer focus elsewhere).
I tried the focus. It is something simple. I need to sleep on it.Quote:
Originally posted by OwenAus
Just a thought - I had a problem with keyboard stuff, until Hilary advised me to first click in the movie (to give it focus). Thereafter it knows the keys are for it (or at least until you click outside the movie and transfer focus elsewhere).
This is for an old arcade style game that I am about half way thru. I want a laser sound when a laser is fired with the space key.
I don't know what are you doing wrong.
Works perfect for me !
OK ... try this modification:
1) delete the command line from the main timeline.
2) add this script for the child-movie "snd":
onClipEvent(enterFrame){
if(Key.isDown(key.SPACE)){this.gotoAndPlay(3);}
}
cheers