PDA

View Full Version : Simplifying script


1ok
03-26-2003, 11:42 PM
Hi

I built a menu, with 6 animated buttons (movie clips in fact). And for each animated button I used this script:


xbtn1.onPress = function() {
if (bt1._currentframe == 1) {
bt1.play();
gotoAndStop(20);
bt2.gotoAndStop(1);
bt3.gotoAndStop(1);
bt4.gotoAndStop(1);
bt5.gotoAndStop(1);
bt6.gotoAndStop(1);
}

xbtn > Invisible button
bt.1, bt.2, .... movie clips.

This script it's not so big, because i'm using just 6 movie clips. But the problem is that i'll have to buid another menu with almost 30 animated buttons. If I use the same script, it will become huge.

Is there another way to do this ?
Something like:

xbtn1.onPress = function() {
if (bt1._currentframe == 1) {
bt1.play();
gotoAndStop(20);
all other movie clips in this menu.gotoAndStop(1);
}

thanks for the help

cheers

Billy T
03-27-2003, 02:55 AM
attached

1ok
03-27-2003, 03:07 AM
Thank you very much !!!!!

cheers

1ok
03-27-2003, 05:48 PM
Billy

I couldn't figure out how to make each button go to a different frame. This script using "for loops" is new for me.

One more little help please.

thks

Billy T
03-27-2003, 11:17 PM
ok because they are all instances of the same mc you will have to change the button actions to something like

on (release) {
_root.gotoAndStop(myLabel);
_root.resetButtons();
this.gotoAndStop("down");
}


and then on the outside of each mc put something like

onClipEvent(load){
myLabel="portfolio";
}

or

onClipEvent(load){
myLabel="contact";
}

and these are the frame labels that _root will jump to

cheers

Billy T
03-27-2003, 11:17 PM
ok because they are all instances of the same mc you will have to change the button actions to something like

on (release) {
_root.gotoAndStop(myLabel);
_root.resetButtons();
this.gotoAndStop("down");
}


and then on the outside of each mc put something like

onClipEvent(load){
myLabel="portfolio";
}

or

onClipEvent(load){
myLabel="contact";
}

and these are the frame labels that _root will jump to

cheers

1ok
03-27-2003, 11:34 PM
Okie dokie

Now it's working !!

thanks !

subquark
03-28-2003, 07:15 PM
Hey BillyT, you helped me consolidate my code and do a function that enables my buttons, so my question is what is:

_root.resetButtons();?

and what would be the advantages of this? (I guess it's only for buttons and not mcs set up as buttons?).

Thanks for shedding light on this Oh Great One! :)

Billy T
03-28-2003, 11:06 PM
Originally posted by subquark

Thanks for shedding light on this Oh Great One! :)

you're wasting you time - pixelwit hasn't been seen around here for ages...

that line of code is basically telling the function you made to run once

the function exists on _root but you are calling it from another timeline so you have to provide the path

that function can only be used with mcs because it uses the gotoAndStop() method of the movieclip object

hope that helps

subquark
03-29-2003, 02:27 PM
Thanks BillyT! Now I get it! So resetButtons is a function like the one you made for me:

function Enable_Buttons(selected) {
for (i=0; i<=Button_Names.length-1; i++) {
if (Button_Names[i] != selected) {
this[Button_Names[i]+"_btn"].gotoAndStop("_up");
this[Button_Names[i]+"_btn"].enabled=1;
}
}
}

Thanks! And the heck with PixelWit, I shall call thee Oh Great ONE or ogo for short! :)

Billy T
03-30-2003, 01:24 AM
Originally posted by subquark
And the heck with PixelWit

gasp :eek:

*Billy runs for cover and awaits the return of the one and only*

1ok
04-04-2003, 05:17 PM
Ok Billy T

Now, i got another problem.

I'm using this script you made (button_stay_down.zip) on the portfolio section of my web site. Each button goes to a different frame and has to call a diferent job.

Each job is a different swf, so for each frame i'm using:

loadMovieNum("job_blabla.swf", 6);

On the first click, everything seems to be ok, but on the second click, the second swf loads and the first doesn't unload.

This swf's jobs will load from level 6 to 33. So i'm trying to figure out a script that unloads all swf's (except 1 to 5 level swf's) and load the right swf job.

Well, I hope you can understand my problem.

You've been helping me a lot.
I don't know how to thank you man !!

Billy T
04-04-2003, 11:09 PM
just load them all into the same level

cheers

1ok
04-07-2003, 03:06 AM
Yep, I realized that, just before you asked. :)

How do I unload a level ?

1ok
04-07-2003, 03:15 AM
That's ok. I found the answer !! :)

cheers