View Full Version : help me not have to redo all my old buttons please?

09-28-2006, 06:28 AM
Hi guys and um, hi guys -

I have a bunch of old buttons that I used to use to play mp3 files - but when I first made them, I didn't know of the wondrous cornucopia of alternatives there were to putting the mp3 in the hit frame - so I made a few thousand that way by hand, totally unaware both that jsfl files could create hundreds of buttons in seconds, and that better codes would play the file as it sat in the root folder, making the flas/swfs much much smaller...

At any rate, thanks to all of you, I don't do buttons that way anymore - but I've got piles of old flas with these buttons, and rather than export the mp3s from each swf using some decompiler, go through and rename them all (because decompilers just use Sound01.mp3, Sound02.mp3... rather than what the sound is called in the library) and then import them into a new fla, use my jsfl file to turn the library mp3s into movie clips - then import all the new buttons back into their original flas and put them all back on the many frames they were originally in -

I'd like to turn them into movie buttons where they are - and put some kind of code on them that tells the regular old button inside the movie clip to go to the hit frame when its holder movie clip button is pressed (onRelease-d that is)

I don't know if I was right to post this in the jsfl forum, because I am asking for an AS code as well, but the making of movie clips from buttons is something that JSFL can do, I just don't know how yet

Basically I need the jsfl to:

1. convert all selected buttons on a given frame's main stage in such a way that the new buttons all stay where the original old buttons were
2. put some AS code on all the new movie clips that tells them each to (in english):
"go to the hit frame of the regular button inside you because there's an mp3 in there that needs to be played"

it may seem a little noobish to do it this way - but I have thousands of buttons - and the old naming convention I used was kinda dumb. I don't want to have to export/rename just so I can use the more efficient mp3-playing-root-folder codes I have now

At any rate, the AS part doesn't have to be included in what I'll call the 'converter' jsfl - I can use a different one to paste on the appropriate AS, which brings me to my final predicament.

the AS code I need for the buttons must have onRelease functionality like this:

//so I can release on the new movie clips because I'm getting to them by
//pushing a regular button on another frame
//and it needs to go back to frame 1 while the sound is playing

Once again - sorry if this method sounds rediculous, but believe me, cobbing it like this is much better than my having to do all that other crap...

If nobody can help with the AS "play the mp3 in the hit frame of the button inside you" part, I'll just repost over on the 2.0 forum, but I figure anyone well-versed enough in JSFL to help me with a 'converter' code can whip out the AS button code I need in no time

I don't care what the new movie clips are called when made by the jsfl - I just need the AS on them to go to the button inside it and simulate a hit when the movie clip is onRelease-d

sorry for the tome, and thanks so much in advance for any help you guys can give. :)

09-28-2006, 08:27 AM

I'm not entirely sure what you're after, so before anything, I'll check!

Are you happy leaving your sound files where they are (I mean, contained within the button, whether that be your old-style button or your new-style movieclip button)? Or do you want to take them out and put them somewhere else altogether?

Are you proposing changing your button into a four- (or more) frame movie clip?

Are you intending to have code on, or in, your buttons? (I advise that since you're making a root-and-branch change, you take this opportunity to avoid doing this.)


09-28-2006, 08:42 AM
yes - I want to leave the regular buttons as they are - what I want is for the jsfl to do what I would do, but to every button on the stage that I highlight, which is:

1. click the button once to select it
2. click F8 and convert it to a movie clip (which means the old button is now inside the movie clip).
3. apply the appropriate actionscript to the movie clip that would tell it to 'hit' or 'mousepress' the button inside it as if it were clicked - thereby (hopefully) playing the mp3

and I need it all to happen onRelease on the movie clip

I don't need to have the jsfl that converts all stage-selected buttons into movie clips also apply whatever AS it's going to take to get the mp3s inside the hit frames of those regular buttons to play

the AS can be applied using a separate jsfl, once I know what AS to use that is

I hope I was clear enough, but if not, let me know

and thanks so much for helping

09-28-2006, 08:48 AM
maybe it would entail first running a jsfl I have that applies an instance name based on the library name of the button - so that AS would have some way of knowing what button to press

I just basically don't know how to get AS to press a button basically

if I knew that I could probably figure out how to get it to happen on release of some movie clip, regardless of whether the button being pressed was inside it or not

09-28-2006, 09:04 AM
or maybe a jsfl could automate finding out whatever mp3 is in the hit frame of a button, and use that name to make the appropriate linkage - which could then be triggered onRelease of a movie clip

I don't know squat here, just spitballing.

09-28-2006, 09:23 AM
OK - taking the first thing first, selecting and converting to a MovieClip. In principle that's not too hard - Select all on the stage, then run through the array selecting each element one by one; check if it's one of your buttons; if it is, use Document.convertToSymbol().

Obviously, the hard bit here is deciding whether the selection is one of your buttons or not. What features distinguish them from everything else? Are they, for example, the only buttons on the stage? Is there something about their name?

Writing the actionscript is easy enough; Frames have got an actionscript : String property that you can set. and you ought to be able to trigger the button by calling onRelease(), I'd have thought.

09-28-2006, 09:29 AM
I can make them the only buttons on the stage by copying and pasting them into a new fla temporarily - but no, the way they are, they are mixed with others I don't want to be altered

I have this jsfl code, which works nicely for applying instance names based on buttons that are selected:

for(i in fl.getDocumentDOM().selection){
fl.getDocumentDOM().selection[i].name = fl.getDocumentDOM().selection[i].libraryItem.name

and this one for applying actionscript to buttons that are selected:

for(i in fl.getDocumentDOM().selection){
fl.getDocumentDOM().selection[i].actionScript = "whateverblahblah);}";

so I guess the same 'picking' method would be used - the first line? I don't know

of course I'm concerned that without the AS that tells the movie clips to 'press' the buttons they hold - it doesn't make much sense to go through a lot of trouble to make the converter jsfl

if you don't know how to make that work, maybe you should let me bother the 2.0 forum for a while and get back to you when I've got a working code for 'pressing' the buttons

09-28-2006, 09:35 AM
Yeah, before you do the JSFL, you should sort out what actions you want - as I say, I suggest trying calling buttonRef.onRelease().

09-28-2006, 09:36 AM
something like this maybe?

var t = [];
var dd = fl.getDocumentDOM()
for(i in fl.getDocumentDOM().selection){
var it = dd.selection[i];
if(dd.selection.getItemType(it.name) == "button"){
for(i in t){
var it = t[i];
fl.trace("obiekt "+it);
if(dd.selection.getItemType(it.name) == "button"){
dd.convertToSymbol('movie clip', it.name.substring(0, it.name.length-4));

i really don't know

09-28-2006, 09:39 AM
ok - thanks - I'll get back to you once I figure out how to make a movie clip tell a button to press itself