Only one movieclip at a time

i have a site, and as usual there are various buttons, and when a
button is clicked an event action occurs. typically running some kind
of movie clip i have placed on the stage…

my question is…
how would i setup the buttons to play one at a time. i mean. if i have
3 buttons (b1, b2, b3) and lets say b2 was clicked, and that mc was already playing… but the user goes to click b3 instead. how would i script the one mc to close out, and tell flash to play b3’s action? i would like all the buttons to behave in this fashion. if one is running, then upon clicking another button it’s actions would detect another mc was running, and simply close it out before running its own actions.

by the way… each button has an associated mc. for example:
b1 runs b1mc, b2 runs b2mc, b3 runs b3mc. thought this would be useful.

i’m thinking some kind of if/else statement built within the button action would do the trick. for example if b2 was clicked, then the user clicks
on b3.

if b2mc_instance playhead = (frame)
then send playhead to nextframe //close out the current mc
else b3mc_instance.play(2) //runs the b3’s associated mc.

i’m trying to make some thing like this, but my programming skills lacking.

any advice with this would be helpful.

thanks

would this be a vb if/else, or is there some way to do it as part of the
on (release) in actionscript?

where could i go to find out more information on how this is done?

does kirupa have tutorial, or some thing about it? i just did a search and came up with nothing. just wondering if there is some kind of flash verbage that i should be using to help describe this situation.

If I understand what you are trying to do, all you need to do is set a variable to trueas soon as your MC starts to play. Then in your on (release) function have a

if (variable == true)

…play this other movie clip instead… then go on to play the intended movie clip

else play the intended movie clip

thanks alot for the feedback sirtimbly!

i wasn’t getting too many replies to this, and i didn’t know where to begin.

have to work on that later though… got a hurricane headed my way.

cheers.

-sqladmin

this is pretty straight forward, but i believe i am doing some thing wrong.

i get no syntax errors, but when b2 is clicked b3mc is still running, and hasn’t closed out.

here is the code for button 2 ‘b2’:

on (release){
if (_root.b3mc == true)
_root.b3mc.gotoAndPlay(49); //49 starts the mc close out sequence.

  else
      _root.b2mc.play(2); //just plays the associated mc.

}

is this wrong?

again all i’m trying to do is have the current movie close out when another on (release) occurs by sending the playhead of the current move clip to the next frame thus playing out the rest of it’s sequence before the next mc begins.

any ideas would be helpful.

thanks in advance

sirtimbly

first of all let me say the chopper challenge is the hardest freakin game man… i only got about 534, and it
took me about 10 minutes worth of trying. then once you get a score like that the walls start spinning… holey smokes man!

and secondly…

you posted a reply to one of my posts:

If I understand what you are trying to do, all you need to do is set a variable to trueas soon as your MC starts to play. Then in your on (release) function have a

if (variable == true)

…play this other movie clip instead… then go on to play the intended movie clip

else play the intended movie clip
dude this is exactly what i am trying to do, but i am having difficulty setting it all up.
i was wondering if you could give me another example. i asked some other guys this question, and they gave me some really
complicated stuff.
was wondering if you could simplify it alittle.

  • sqladmin

Try…
on(release){
mc2.gotoAndStop(1);
mc3.gotoAndStop(1);
mc1.play();
}
On the button that plays mc1.
on(release){
mc1.gotoAndStop(1);
mc3.gotoAndStop(1);
mc2.play();
}
For mc2, etc.

**dunga::: your flash footer is too cpu intensive… have a option to turn off the particles.

…edit… it seems to have a bug when you play around with it, i can get stuck with particles on and slow everything down.**

sqladmin I would use varables like mentioned and if statements. such as on the first frame have a set of if statments to determine what button was pressed and what actions to do.

let me see if i can find a example of what i mean.

ok my idea before was a little off. lol

set up a variable called let say “active”

then depending on your layout will determine the code but here is a general concept with the idea that your button are movieclips and your in and out animations are in the mc’s.

this code would go on the timeline.


//set your variable
active=0;
 
button1.onRelease=function(){
if(active==2){
button2.gotoAndPlay("outanimation")
}
 
if(active==3){
button3.gotoAndPlay("outanimation")
}
 
// set your variable for the next if statement
active =1; 
this.gotAndPlay("startanimation")
}
 


button2.onRelease=function(){
if(active==1){
button1.gotoAndPlay("outanimation")
}
 
if(active==3){
button3.gotoAndPlay("outanimation")
}
 
// set your variable for the next if statement
active =2; 
this.gotAndPlay("startanimation")
}
 


button3.onRelease=function(){
if(active==1){
button1.gotoAndPlay("outanimation")
}
 
if(active==2){
button2.gotoAndPlay("outanimation")
}
 
// set your variable for the next if statement
active =3; 
this.gotAndPlay("startanimation")
}

it is true that this could be simplified but i set it out like this so you can understand how it works, its a simple method and works well, as long as it works thats all that matters. :slight_smile:

edit:: you could also put the variable active on the start of the buttons animation…

say you selected button1, on the keyframe of the frame label where your button intro animation start put active= 1;
, same applies for button2 put active=2 on the timeline where the buttons animation starts, this way you wont have problems with the if statments and declaring a new value for the variable.

I just use behaviors… :-\

i think this is what i was looking for except for the fact that my buttons are in not movie clips. i get the idea now.

i really appreciate the break down man… this helps me out alot.

dunga… your solution would work fine except my movie clips contain the out animations, and sending the play head to the first frame would bring an aprupt stop to the flow of the navigation in general.

i could set the gotoAndStop() on the out animations of all the movie clips, but then they would all play the out animations at the same time.

thanks again for the feed back.