-
How do you use the key press to play sounds from the library?
Action Script 2.0
I've been making soundboards for a couple of years, but in my opinion I do it in a rather hacky inefficient way.
Previously I have been creating a movie clip with the sound on frame 2, and a simple stop on frame 1. I then add code to the movie clip basically saying onkeypress ("Y") gotoandplay frame 2.
This method takes forever. I am an AS novice, I have wrestled with it on many occasions. I just don't have the brain for it. Was wondering if there's a basic code that you guys could help me with to tell it that when this key is pressed, play this sound in my library.
Any help appreciated, thanks
-
I'd have thought this would be an easy one to answer, has no one got anything on this?
-
Its very simple as you do in your house same thing i do in library in order to URL=http://www.funrocker.com/song-pk.htmlplay song.
-
Flashkit historian
Sj
You'll find your time here very short if you continue to yank up old threads for the sake of a post count.
-
*edit*
Didn't see you're using AS2. Perhaps this can still push you in the right direction.
----
This could get you started. In main.fla I just have a sound with the Linkage identifier as "Sound1", and this .as file is the DocumentClass.
PHP Code:
package {
import flash.events.KeyboardEvent
import flash.display.MovieClip
import flash.media.Sound
import flash.media.SoundChannel
public class VirtualDJ extends MovieClip {
private var sChannel:SoundChannel;
public function VirtualDJ():void {
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPress)
sChannel = new SoundChannel();
}
private function onKeyPress(ke:KeyboardEvent):void {
//trace(ke.keyCode)
var s1:Sound1 = new Sound1();
sChannel = s1.play()
}
}
}
You can check to see which keycode was pressed, play different sounds, etc.
I (Love | Hate) Flash.
----
Save a version back so others may help you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|