The Team Jackulator Forums
March 28, 2024, 11:49:52 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
   
   Home   Help playlist Arcade Search Media Downloads Login Register  
The Jackulator 9000 Forums
Pages: [1]   Go Down
  Send this topic  |  Print  
Current Topic Rating: *****
You have not rated this topic. Select a rating:
Author Topic: Assigning sounds to a key?  (Read 3139 times)
0 Members and 1 Guest are viewing this topic.
Nevermore
baby jack
*
Offline Offline

Posts: 11


Awards
« on: May 29, 2013, 09:35:42 am »

I'm currently making a Karl Pilkington SB, and it's currently got over 300 sounds, so I'm wondering in there's a way to assign sounds to key presses? For eg. pressing 'o' and the soundboard says "okay". (I'm using Macromedia Flash cool  I'm quite new to this, so I apologise if this is a nooby question.

Thanks
Logged
CallMeBronco
I'm Mr. Buznik's dick
MEGAMEMBER
Team Jackulator
****
Offline Offline

Location: I don't know
Posts: 2472

I'm dead! Help me out! I'm dyin' here!


Awards
« Reply #1 on: May 30, 2013, 04:47:24 pm »

why hello there, I thought we weren't receiving new members  T_Shock3 oh well, glad to have you onboard!

As your doctor, I recommend you take a look at this topic;

http://www.jackulator.com/smf/index.php?board=106.0
this is a program Jack created to make soundboards really easily. If you also want to learn how to use flash, there's tons of topcis here to look through.

why you're in luck! Just now I was able to find a txt file I saved for myself years ago with lots of action scripts ready to just copy/paste into flash  smiley [attached]

unfortunately I don't have written down exactly what everything does, hopefully you can figure it out.  cheesy I'm afraid it's been so long I don't remember how it works but Jack could tell you probably.

* randomflashscript.txt (1.91 KB - downloaded 103 times.)
Logged

my jackulator tribute video: https://www.youtube.com/watch?v=mtbIpQTjH7M



"Nothing worth having comes without some kind of fight" - Bruce Cockburn



Nevermore
baby jack
*
Offline Offline

Posts: 11


Awards
« Reply #2 on: June 01, 2013, 03:14:17 pm »

Cheers for the help, man. I'm sure this'll come in handy.
Logged
jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #3 on: June 20, 2014, 05:18:14 am »

you have to use a key listener -- although I'm not sure how efficient it'll be to do this because ultimately you can only say as many things as there are keys on the keyboard

but it would be something like this:

Code:
keylistener = new Object();
keylistener.onKeyUp = function() {
if (Key.getCode() == Key.SHIFT) {
trace("you just pressed the SHIFT key!");
}
};
Key.addListener(keylistener);

and so if you wanted to code a specific sound to play you would have to create a sound object first like:

Code:
sound = new Sound();
keylistener = new Object();
keylistener.onKeyUp = function() {
if (Key.getCode() == Key.SHIFT) {
sound.loadSound("theSoundYouWantToPlayWhenYouPushTheShiftKey.mp3", true);
}else if(Key.getCode() == Key.SPACE){
sound.loadSound("theSoundYouWantToPlayWhenYouPushTheSPACEKey.mp3", true);
}
};
Key.addListener(keylistener);

and there's a list of all the various key codes for the keys: http://people.uncw.edu/tompkinsj/112/flashactionscript/keycodes.htm

so you could go:

Code:
sound = new Sound();
keylistener = new Object();
keylistener.onKeyUp = function() {
if (Key.getCode() == 48) {
sound.loadSound("theSoundYouWantToPlayWhenYouPushThe0Key.mp3", true);
} else if (Key.getCode() == 49) {
sound.loadSound("theSoundYouWantToPlayWhenYouPushThe1Key.mp3", true);
} else if (Key.getCode() == 50) {
sound.loadSound("theSoundYouWantToPlayWhenYouPushThe2Key.mp3", true);
}//et cetera...
};
Key.addListener(keylistener);

and in order for the sound object you created to play you have to make sure the mp3s are in the same folder as the SWF file

otherwise you have to specify the location with like:

Code:
sound.loadSound("someFolder/theNameOfTheMP3.mp3", true);
Logged

Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  



Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC | Sitemap Valid XHTML 1.0! Valid CSS!
Page created in 0.2 seconds with 20 queries.