here's a zip of all four (3kb):
http://www.jackulator.com/FILES/JSFL/4JSFLs.zipwhat the package contains:
1. _makeButtons(attachSound)-For MP3s in LIBRARY of FLA file.jsfl
2. _makeButtons(loadSound)-For MP3s in Same Folder as SWF File.jsfl
3. _makeMovieClips(attachSound)-For MP3s in LIBRARY of FLA file.jsfl
4. _makeMovieClips(loadSound)-For MP3s in Same Folder as SWF File.jsfl
using these JSLF files, you no longer have to create buttons by hand!
please read the following:other than opening your soundboard's FLA file and physically dragging the library mp3s into the Down frame of buttons, or as is the case with movie clip buttons, dragging the library mp3s to say frame 2 of the movie clip (making sure to put 'stop();' in frame 1), there are two BETTER ways of making buttons and movie clip buttons play sounds - using simple Actionscript codes for either the 'loadSound' or 'attachSound' methods:
loadSound - loads up a sound that's in the same folder as your soundboard, but is not in your soundboard's library (which you can see if you have your soundboard's FLA file open)
attachSound - loads a sound that IS in your soundboard's library
the benefit of loadSound is that you can have an enormous soundboard on your computer's hard drive, but keep your soundboard's FLA file small so that it doesn't freeze up or take a long time every time you edit something - the problem with loadSound is that if you want to post your soundboard to the Internet, you should upload it as a ZIP file so people can download it and run it on their computers, because if you just post the board and all the MP3s you use for it into some folder on the Internet, even though people will be able to see your soundboard, whenever they click a button they will have to wait for their browser to download the sound first before it will work - - there are ways around this, namely pre-loading the sounds, but if you do that then there is no difference between using loadSound and attachSound, because in both cases the user must wait for Flash to load all of the sounds - actually, in this scenario attachSound is faster than loadSound because a browser will probably take longer to download each individual sound vs. just the entire soundboard all at once if you used attachSound
but like I said, if your soundboard is huge, if you use attachSound, you have to have all of the MP3s physically inside your soundboard, which makes it a huge file, which eventually makes it react slowly to every edit you make in the FLA file
bottom line - I'd recommend using loadSound if you have a soundboard with more than 500-1000 audio files, until you publish it, at which time you'd either just preload all of the sounds at start-up, or you'd do a find/replace and change the actionscript on all of your buttons to attachSound, import all of the MP3s and set their ExportForActionscript linkage - and I have JSFL files for all of this...
so be aware, you sort of need to know ahead of time which way you want to go beforehand, but ultimately, if you think about what you want to do and what each JSFL file does, and you're careful with what you enter in the boxes for find/replace, you can reverse just about any changes you make, and get exactly what you want
all of that said, (and among a few other goodies) I have JSFL files for:
1. creating a bunch of simple buttons that use loadSound
2. creating a bunch of simple buttons that use attachSound
3. creating a bunch of movieClip (pop-up, mouse-release style) buttons that use loadSound
4. creating a bunch of movieClip (pop-up, mouse-release style) buttons that use attachSound
with all of these four JSFL files, the text on the buttons is created from the name of the MP3 files you have (minus the extension), so you must import MP3 files to an FLA file, then go to Command>Run> and browse to wherever you keep your JSFL files
you have to keep in mind though, if you're using loadSound, and you want to create a bunch of buttons or movieClip buttons, the whole point of loadSound is so you don't have to have all of the MP3s inside the library of your FLA file, and consequently, your soundboard - so in order to have your soundboard/FLA have ONLY the buttons or movieClip buttons you create and not the MP3 files as well, all you have to do is open a new FLA, import the MP3 files, run the right JSFL, and then once your buttons or movieClip buttons are made, just copy THOSE off the main stage and into your main soundboard's FLA file - that way the MP3 files don't come along for the ride
BUT! even if you are using attachSound you should still import the MP3s into the library of a blank FLA file before running the JSFL file because the way the JSFL file is coded, it will just take all of the sounds in the library and make buttons or movieClip buttons out of them - so if you had a bunch of buttons made, and then you imported a bunch of MP3s to the same library so you could use the JSFL that creates movieClip buttons, the JSFL would also try to create new movieClip buttons out of all of the MP3 files you were already using for your regular buttons - but it wouldn't work because it would try to name all of the movieClip buttons the same thing as your buttons - and aside from having to click cancel on each new movieClip button it tries to save as the same name as a previously-made button, it might also cause problems
so just get in the habit of always using a new blank FLA file any time you want to create a bunch of new content for your soundboards - also helps because you can save them and have them as backups and also keep track of your progress or whatever-----------------------------------------------------------------------------
SOME THINGS TO REMEMBER WITH THESE JSFL FILES!-----------------------------------------------------------------------------
before creating buttons with these JSFLs, click the text tool and select the font and size you want for your buttons!also, the JSFL files are set up to work as-is, so that once you understand what they do, you don't need to do any more coding - they'll just work
ALSO - and this is BIG - whenever you use JSFL files to make buttons you have to set your folder options set to view extensions - for instance, in Windows Explorer for XP if you go to any folder then go to Tools>Folder Options>View and and you make sure 'Hide Extensions for Known File Types' is checked, when you import your mp3s into the library in Flash, you'll note that the mp3s don't have the .mp3 extension - BUT - you need the .mp3 extension in order for the JSFL to properly make your buttons - so make sure you don't have the extensions hidden!!!!!however, there are two things you should know about the two JSFL files for making movieClip buttons - and just movieClip buttons in general:
1. with movieClip code you must always refer to the _root, or else Flash will think the code is for the movieClip itself, and here's more detail
here is the Actionscript code that the JSFL for creating movieClip buttons with the loadSound method puts on all the new ones it makes:
onClipEvent(mouseUp) {
if(this.hitTest(_root._xmouse,_root._ymouse)){this.pressed=true;
_global.MySound.stop();
_global.MySound = new Sound();
_global.MySound.loadSound("TheMP3Name.mp3", true);
_root.gotoAndStop(1);
}
}here's each line of code and what it does:
1.
onClipEvent(mouseUp) { means that however many frames per second your soundboard is set to play at (and it doesn't matter for soundboards as long as it's over 6 - the default is 12 or 18 I think) is how many time per second this code 'fires', but all it's basically telling Flash is, "whenever the mouse is released, run the following code:"
2.
if(this.hitTest(_root._xmouse,_root._ymouse)){ means that if the mouse is over the top of this particular button - so so far we have told flash, "whenever the mouse is released, check to see if it's over the top of this button, and if it is, run the following code:"
3:
_global.MySound.stop();this line means, "stop the sound that is already playing in the MySound sound object"
regardless of whatever you name your sound objects (and I'll get to this in a minute), having the stop code on your buttons and movieClips execute before the rest of the code that plays the sound means that you can cut off phrases with other phrases - so if you had a button that played the Jim Carrey line, "I desperately wanna make love to a schoolboy" (hah) and you also had a button called "MotorizedCart' that played the MP3 you cut from "I got robbed by a sweet old lady on a motorized cart", by clicking the first one and only letting the audio file get to "I desperately wanna", you could then press the MotorizedCart button, and you'd hear "I desperately want a motorized cart!"
using this technique of cutting off phrases with others requires some skill and finesse, but can produce interesting new phrases you can 'create' on the fly, without having to edit and splice them together manually using some kind of sound editing software
it also keeps you from being able to play multiple sounds at the same time by accident, which is a big no-no on soundboard pranks because it instantly lets the person being pranked (most of them) know that they're talking to some kind of machine (because most real people can't utter two phrases at once)
but - if you don't like this functionality, since it's already built into the way the JSFLs code the various button types -- it's easy enough to remove, so just shoot me a pm I'll tell you how
4-5.
_global.MySound = new Sound();
_global.MySound.loadSound("TheMP3Name.mp3", true);these lines mean, "recreate the 'global' sound object called 'MySound' and use it to play an MP3 called 'TheMP3Name.mp3', where you'll in the same folder that this FLA file and it's SWF file are (once it's exported)"
but here's where it gets slightly interesting - and there are two issues
issue 1. Flash Saves to Temp Location Until You Save The FLA File Somewhere
if you use this JSFL, and then go to Control>Test to see how all your happy new movieClip buttons work, you'll be disappointed because until you save an FLA somewhere specific, Flash automatically exports the test SWF file to a TEMP location somewhere on your C: drive most likely, so since the MP3 files your movieClip buttons refer to aren't in that temp folder, it will seem like the movieClip buttons don't work - they do, you just have to save the FLA to whereever those MP3 files are, and THEN test it - then you'll see that they work
issue 2. Using 'Root' When Talking to Movie Clips
the other thing to bear in mind with these two lines of code is an even more interesting thing - the use of the prefix '_global' before the name of the sound object, which in this case is 'MySound', whereas you'll note after running the JSFL files that create the regular buttons, the name of the sound object is just 'sound' - and that creates something of a conflict given the stop sound functionality addressed in the explanation of the previous line of Actionscript code
here's a likely scenario - you already have (or plan to have) a bunch of REGULAR buttons on the main page of your soundboard, and you're just creating the movieClip buttons to go on some other page of the soundboard (to be reached by clicking some of the buttons on the main page) -- you'll want the code on your movieClip buttons to refer to the same sound object as the regular buttons - otherwise you won't be able to take advantage of the stop sound functionality from the previous line of Actionscript code (unless you changed it to stopAllSounds(); but that's another topic)
so you might ask, "Since you like having the ability to cut off one phrase with another and not having to worry about clicking two things at once by accident, why did you make the JSFL file so that it created movieClip buttons that use different sound objects than the regular buttons?"
1. because if I wanted to use the sound object 'sound' that the regular buttons use, since we're now dealing with movieClip buttons, I'd have to have the prefix '_root' before the name of the sound object - but unlike regular buttons, if you didn't already create a sound object in the main soundboard first by doing something like this in the Actionscript window for Frame 1 of your soundboard:
sound = new Sound();then any reference to _root.sound on a movieClip would be referencing a non-existent sound object, and no sound would play - so since I wanted the JSFL files to create buttons that worked on their own, without any additional coding, I had to use a GLOBAL sound object, hence the '_global' prefix - the global sound object CAN be created from within a movieClip because it's global - whereas a sound object created by any and all of your regular buttons on page 1 of your soundboard that have the 'sound = new Sound(); in their Actionscript code CAN be created by regular buttons - just not movieClip buttons - even if they are on Frame 1 like the regular buttons are - that's just the way movieClips work - often times if you run into problems with a movieClip not executing code properly it's because you didn't have '_root.' before something in the movieClip's Actionscript code
BOTTOM LINE: if you want the movieClips to use the same sound object as the regular buttons (you do), then just download these two JSFL files and delete the same two you got from the ZIP file linked to at the top of this topic:
http://www.jackulator.com/FILES/JSFL/_makeMovieClips(attachSound)-ForMP3sInLIBRARYofFLAfile.jsflhttp://www.jackulator.com/FILES/JSFL/_makeMovieClips(loadSound)-ForMP3sInSameFolderAsSWFfile.jsfljust be aware that if you run them without first creating the sound object 'sound' somewhere on the main page of your soundboard - either in the Actionscript window for Frame 1, or on any regular button, the instances of '_root.sound' will refer to a sound object that hasn't been created yet, and will not ultimately launch any audio file - no biggie though since you're probably creating some regular buttons first before you start adding movieClip buttons on other frames of your soundboard - this is all just FYI - so depending on how motivated you are you can understand how and why this stuff works - helping you do it all right the first time....
6-8.
_root.gotoAndStop(1);
}
}these lines just tell Flash to send the SWF file back to Frame 1 - where all of your regular buttons are, and that the code for this movieClip button has ended