How do I create buttons that shows that I clicked on them

I have a menu that have four buttons; start, about me, portfolio and contact.
If the visitor hover above the buttons they change color and when I click on one of them the button should change to a different color and stay that way until I click on one of the others. Just to show people where they are.

But the code just get so big. I have to add code to each and all of buttons telling them what to do if I click on them and not the others and when hovering above them.

Is there a easier way to just collect the code and put it to a single frame or something? I know how to work with if/else and variables but that´s pretty much it when it comes to ActionScripting.

Best regards Jonas

Hiya,

just follow my example and you’ll be fine. This makes the last clicked button inactive. Check it out.

Download >> LastClickedButton.fla

Any questions just ask me.

Ads.

Try out this…simple you can increase the number of MCs passed

Int this code and b1 and b2 are the MC on the stage with two frames. We’ve added stop() on the each frames to avoid loop. Write the code on the first frame…

  
function findClick(firstmc, lastmc) {
  firstmc.gotoAndStop(2);
  lastmc.gotoAndStop(1);
}
/:b1.onRelease = function() {
 findClick(_root.b1, _root.b2);
};
/:b2.onRelease = function() {
 findClick(_root.b2, _root.b1);
};


see the attached file

Yaa…as-clark20’s idea is good… more compact

Jesus Christ, how good! Thank you both!