The Team Jackulator Forums
April 20, 2024, 07:26:38 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  
This topic has not yet been rated!
You have not rated this topic. Select a rating:
Author Topic: all four JSFL files needed to automatically create buttons and movieClip buttons  (Read 6703 times)
0 Members and 1 Guest are viewing this topic.
jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« on: December 15, 2008, 05:36:37 pm »

here's a zip of all four (3kb):

http://www.jackulator.com/FILES/JSFL/4JSFLs.zip

what 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.jsfl
http://www.jackulator.com/FILES/JSFL/_makeMovieClips(loadSound)-ForMP3sInSameFolderAsSWFfile.jsfl

just 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
Logged

jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #1 on: December 15, 2008, 06:01:35 pm »

a quick explanation of why/how you use movie clip buttons:

you have a bunch of different ways your soundboard character can say 'hello', but rather than have them all on the main stage of your soundboard eating up space you could be using for other things, you can put them all on a different frame of your soundboard, and have just one button that says 'hello' on it that when pressed sends the soundboard to the page where the hellos are!

those hellos on the other page could be regular buttons, but what would happen is on your main page you'd have your 'hello loader' that when pressed sends the soundboard to the page with the other hellos, but then when you got to that page, you'd have to click again - believe it or not, it's faster to not have to click twice when you're soundboardin' - so to get around this we use what we call pop-up windows for lack of a better term - which is just a combination of a loader button the main page, a bunch of movieClip buttons on some other page, some code on the buttons and a 'blocker' - and here's how it works:

1. you open a new FLA file and import all the hellos you've got into the library
2. you go to Command>Run and wherever you keep your JSFL files, and run either "_makeMovieClips(attachSound)-For MP3s in LIBRARY of FLA file.jsfl" or
"_makeMovieClips(loadSound)-For MP3s in Same Folder as SWF File.jsfl" (depending on whether you want to use the attachSound or loadSound methods)
3. after the buttons are created, you select and copy them and paste them into your main soundboard (and then copy/paste the library mp3s as well if you're using the attachSound method)
*note: you have to be careful when you paste the buttons or mp3s into your soundboard's FLA, if you already had a regular button called Hello1, you couldn't paste in a newly-created movieClip button also called Hello1 - and Flash would ask you if you want to replace - but it only asks you if you want to replace the ones that were duplicates - it doesn't tell you which ones were.... frustrating - just make sure you're aware of this phenomenon and name your mp3 files accordingly
4. you go to frame 2 of your soundboard's main timeline, and you right-click and insert a blank keyframe
5. you immediately go to the main timeline and click Frame 1, then go to Window>Actions, and in the Actionscript window type:
stop();
and then close or minimize the Actionscript window
*any time you create a new frame in either the main timeline of an FLA file or in the timeline of a movieClip you AUTOMATICALLY put a stop(); action in Frame 1 of the movieClip or the main timeline - otherwise when you test or export the SWF file it will just loop through all of the frames you have!! no good unless you want it do do that (you don't with a soundboard...)
6. go to frame 1 and select all the newly-created movieClips from steps 1-3 and cut them - and paste them into the new blank keyframe you created in frame 2
7. go back to frame 1 and create your 'hello loader' by clicking the text tool, typing in whatever you want like Hello, then go to Modify>Convert to Symbol, make sure 'Button' is selected, and maybe name it HelloLoader and click Ok (don't just name it Hello) chances are one of your hellos is already named that - put 'loader' or something on the end so there's less of a chance you'll have problems later trying to paste in other buttons or mp3s
*note, before you convert the text to a Symbol, if it isn't already set up this way, go to Window>Properties, make sure the text you just typed is set to 'Static Text' in the properties panel, and that 'Anti-alias for readability' is selected over on the right
8. make sure the hello loader you just created is selected (by deselecting it first if you need to), and then go to Window>Actions and type in:

on(press){
gotoAndStop(2);
}


Now, when you test your soundboard, when you click the hello loader and hold the mouse down -- the soundboard will advance instantly to frame 2 where your hello loaders are - you release the mouse over whichever hello you want to 'say' and the soundboard immediately goes back to frame 1 again!

of course, if you had a bunch of names - you'd do the same thing - open a new FLA and create your movieClip buttons, import the names and run the JSFL file - then copy them into your soundboard's FLA file, but THIS time instead of creating an empty keyframe on frame 2, you'd create one on frame 3, paste your new movieClip buttons there - then create your Names loader - but this time the code on the loader would be:

on(press){
gotoAndStop(3);
}


it's that simple - just make sure the frame on your loader button matches the frame where its corresponding movieClip buttons are and you're all set
Logged

RussW
MEGAMEMBER
Jack Master
****
Offline Offline

Posts: 319


Awards
« Reply #2 on: December 16, 2008, 01:46:14 am »

so pretty much the only button we will have to make is the loader button for the popups?
Logged
jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #3 on: December 16, 2008, 06:55:44 pm »

yes sir!  cheesy
Logged

thegoldenphone

jackboard fan
**
Offline Offline

Posts: 38


Awards
« Reply #4 on: October 23, 2009, 03:49:37 pm »

is there code to make the buttons change color on rollover and click?
Logged
jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #5 on: October 23, 2009, 05:22:07 pm »

not sure what you're asking, but check the attachment I added and let me know if that helps

* aLittleAboutColoringCodeAndJSFLs.fla (40 KB - downloaded 107 times.)

* aLittleAboutColoringCodeAndJSFLs.swf (9.57 KB, 940x562 - viewed 372 times.)
Logged

thegoldenphone

jackboard fan
**
Offline Offline

Posts: 38


Awards
« Reply #6 on: October 23, 2009, 07:30:08 pm »

right now i have the jsfl code that turns all the sounds in the library into a button. i want the code to make the buttons change color on rollover, and change color on click cheesy
Logged
jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #7 on: October 23, 2009, 08:25:03 pm »

right now i have the jsfl code that turns all the sounds in the library into a button. i want the code to make the buttons change color on rollover, and change color on click cheesy

it's not that simple man, first off, there isn't already 'the jsfl that does such and so' - it would  need to be written by me for you

and given that I don't even know what it is your trying to do I can't just shoot in the dark and upload something that won't meet your expectations

could you give me some more detail about exactly what it is that's supposed to happen - pretend I don't know anything about flash

are you talking about a JSFL that will create buttons that change color when you drag the mouse over them (be specific man), if so, then you've got everything you need already in the FLA file I attached
Logged

thegoldenphone

jackboard fan
**
Offline Offline

Posts: 38


Awards
« Reply #8 on: October 24, 2009, 01:08:36 am »

ill try to explain my situation the best i can, i use the jsfl to make buttons out of the sound clips in the library. after the buttons are made and organized i have to manually double click on the button and add frames on "over" and "down" and change the color for each so the button changes color on rollover. its very time consuming for large boards.  tongue  there is no way to do this for ALL OF THE BUTTONS AT THE SAME TIME other than a jsfl
Logged
jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #9 on: October 24, 2009, 08:28:21 am »

I see -- I have a very simple solution for you

instead of using a JSFL that just creates buttons, you'll be using a new JSFL that is a combination of the JSFL I provided with the FLA attached in my previous topic and the JSFL for creating 'movie clips' (identical to the one for buttons, except it creates movie clips)

what it will do is create movie clips out of all the mp3s in your library, give them an instance name, and then apply the code in the FLA I attached before so that the instance names of all the movie clips ends up in the array for the buttons you want to have the color-changing code apply to

you just have to put the code from the FLA into whatever FLA you make your buttons with

so I'll just make the FLA for you and give you some pointers on how to change the color to your liking -- and you don't have to, but if you could kick me a small donation at our paypal page (bottom of every page here at the site) that'd be great

back in a bit  cool
Logged

jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #10 on: October 24, 2009, 10:26:36 am »

I attached a ZIP file of the FLA and the JSFL file you'll run after you import mp3s to your library

enjoy  cool

PS: I also included an example I made with Jack mp3s -- in order to make them all fit I had to make the stage height and width larger and then selected the background layer and went to Windows>Align, selected the 'To Stage' button, then clicked the 'Match Width and Height' button so the background would be the same size as the stage, then clicked the 'Align Horizontal Center' and 'Align vertical center' buttons to center the background on the stage, then locked the background layer again  -- so you can repeat those steps if you want to increase/decrease the size of your board depending on how many mp3s you have

check the Jack Example I attached to see what I mean  cheesy

by the way - it took 99 seconds to make all 450+ movie clips with the JSFL - so it's not instantaneous or anything  smiley

* colorizedMovieClipButtonsFromLibraryMP3s.zip (9.12 KB - downloaded 101 times.)

* TheJackExample.swf (4198.88 KB, 1100x700 - viewed 407 times.)
Logged

thegoldenphone

jackboard fan
**
Offline Offline

Posts: 38


Awards
« Reply #11 on: October 24, 2009, 01:24:41 pm »

with the old jsfl i used i just change the mp3 extension in the jsfl to wav with notepad because i get problems working with mp3s in flash. rolleyes i dont see any mp3 extensions in the jsfl u posted. the problem i have with mp3s is that they dont import into flash for some reason and ive read that flash 10 isnt too compatible with mp3s. i tried the jsfl with wavs anyway and it created words out of the library, but they are unclickable. i looked at the properties and it says their movie clips.   tongue
Logged
jackulator
... --- ...
Administrator
jackulator.com
******
Offline Offline

Location: Eastwick, Rhode Island
Posts: 10507


"Twenty pushups a day..."


WWW Awards
« Reply #12 on: October 24, 2009, 04:15:50 pm »

you can't use WAVs with this - sorry

but yeah they're supposed to be movie clips...

did you read anything from the first FLA I attached?

there is a difference between movie clips and buttons

if all you wanted to do was have buttons play sounds when pressed you could use a different jsfl, but then you'd have to manually go in and edit each button to have different colored mouse states... by using movie clips you can do both - flash thinks of these movie clips AS buttons because the code tells it what to do to them in different mouse states

plus you can use the same code once and have it apply to all of them... otherwise you'd have to have the same code on each movie clip.

so yeah.. turn your WAVs to MP3s and this will work like a champ. I'd recommend Format Factory (free).

when finished, don't try to import more than 90 files at a time into flash though - it won't import that many at once.
Logged

thegoldenphone

jackboard fan
**
Offline Offline

Posts: 38


Awards
« Reply #13 on: May 22, 2010, 01:18:07 pm »

I wish to have instance names other than the file name for the movieclips buttons. Something like sb1, sb2, sb3, etc... I believe its possible to do with a for statement and arrays inside the jsfl. what would be the javascript to do that? . Im using the movieclip attachsound jsfl method btw.  cheesy
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.806 seconds with 22 queries.