Click to See Complete Forum and Search --> : sound with key press
tmoore935
11-13-2002, 03:41 PM
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?
necromanthus
11-13-2002, 06:23 PM
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 !
;)
tmoore935
11-13-2002, 11:03 PM
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 can not get this to work
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.
OwenAus
11-13-2002, 11:22 PM
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).
tmoore935
11-13-2002, 11:48 PM
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).
I tried the focus. It is something simple. I need to sleep on it.
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.
necromanthus
11-14-2002, 02:02 PM
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
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.