Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button with MC's 1

Status
Not open for further replies.

natedeia

Technical User
May 8, 2001
365
US
I have a few buttons, they activate or make visable/call on MC's. Question is, when the buttons are rolled over, how can i make the MC nonvisable? Is there more effective code than this, that follows?

on (rollOver, rollOut) {
_root.mch._visible = "1";
_root.mca._visible = "0";
_root.mcb._visible = "0";
_root.mcr._visible = "0";
_root.mcc._visible = "0";
}

on the layer i have them all "0", on the button is the code above, so when everything loads, the MC's are "0".

can i make it with a roll out function or something?
any better way of doing the above? thanks everyone!
 
Seems a bit odd that the code fires on rollOver and rollOut to me.

You could number the movieClips mc1 through to mc5 instead of using the alphabetical codes that you do and then use a loop to control them.

on (rollOver) {
// set which clip is to be shown

selected = 2;
for (i=1; i<=5; i++) {
// hide all the clips
_root[&quot;mc&quot;+i]._visible = false;// or &quot;0&quot;

}
// show selected clip
_root[&quot;mc&quot;+selected]._visible = true;// or &quot;1&quot;

}


This is a lot of code compared to what you had but it's more versatile - if you add more buttons to your movie, with more clips attached, you just increease the amount of loops you go round - I've got a couple of movies where over 100 elements are controlled by a single loop in this way.

As for using a function, take the above code as it is but without the button action and it should work fine.

function buttonAction(selected){
for (i=1; i<=5; i++) {
// hide all the clips
_root[&quot;mc&quot;+i]._visible = false;

}
// show selected clip
_root[&quot;mc&quot;+selected]._visible = true;
}


...call it with...

on(rollOver){
buttonAction(mcnumber);
}


where &quot;mcnumber&quot; is replaced with the movieClip number you want to show.

If your function is...

 
&quot;If your function is..&quot;

Sorry, my editing is slipping.
 
Nat,
Is this still for your side menu? like testgigforum?
mywink2.gif
ldnewbie
 
yea, oldnewbie, it seems to work ok except for on rollout the mc stays visable. just wanted to keep it where the roll out over the button and mc would make it disappear.

Wangbar, i need to look at your code more closely, have not gotten that deep into it &quot;code&quot; too much.
How is this hiding other clips, or the clips from being visable when the timeline/frame is loaded? I am assuming that i would put all the MC's in one frame, maybe put my code above to make them where they are not visable? Then place your code above on each button...

How is this hiding other clips??? Thanks bro!
selected = 2;
for (i=1; i<=5; i++) {
// hide all the clips
_root[&quot;mc&quot;+i]._visible = false;// or &quot;0&quot;

 
Basically when the code runs it hides everything then makes the clip you select visible.
 
Nat... Fail to see how this will help you when trying to select something in the submenus. Post a link, if you will, when you get it working... Just would like to see it!

Regards,
mywink2.gif
ldnewbie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top