Navigation buttons

Situation: I’ve got 3 buttons on the left side of my flash movie that each fade in their corresponding content on the right. The buttons currently have a visual “glow” that fades in and out as you mouseover them. BUT, I want the glow to stay if you click on the button.

         **Problem:** I tried setting _global.clicked3 to 1 on release, and then (by design) the glow should not fade out. The on rollOut should check to see if _global.clicked3 = 0, and if it does, fadeOut, if it does not, do nothing.

Then of course each time you click a button it fades out the “glow” on the other two buttons, and sets their global variables to “0”.

         As soon as I put the IF statement in the on rollOut, the "glow" won't fade out anymore on rollOut.

Maybe there is another way to do this? 1) Keeping my nice fading glow effect, 2) having it stay when you click a button, and 3) have it fade the other 2 buttons out.


  on (release, releaseOutside) {
  _root.content.fadeOut(_root.content.button1.button_fade);
  _root.content.fadeOut(_root.content.button2.button_fade);
  
  _root.content.fadeOut(_root.content.content_group1);
  _root.content.fadeOut(_root.content.content_group2);
  _root.content.fadeIn(_root.content.content_group3);
  
  _global.clicked1 = 0;
  _global.clicked2 = 0;
  _global.clicked3 = 1;
  }
  
  on (rollOver) {
  _root.content.fadeIn(_root.content.button3.button_fade);
  }
  
  on (rollOut) {
  if (_global.clicked3 = 0) {
  _root.content.fadeOut(_root.content.button3.button_fade);
  }
  }

Note: I don’t know why those spaces (at end of lines) are showing up here on kirupa, it looks fine when I am in edit mode.

My source is too big to upload, so I put it on my web server. Here are the URLs to view the movie, and to get the source:
[http://www.kylehaskins.com/files/flash1/index.html](http://www.kylehaskins.com/files/flash1/index.html)
[http://www.kylehaskins.com/files/flash1/home.fla](http://www.kylehaskins.com/files/flash1/home.fla)

In the flash movie the buttons live here:
content (movieclip) > buttons (layer) > frame 57
button1_mc, button2_mc, and button3_mc each contain the buttons with actionscript.

Note: I’ve got an “if (_global.clicked3 = 0)” on the 3rd button, but a “==” on the other two, so in 1 & 2 you can see them fading in and out. But #3 won’t work.

i think you’re making this harder than it is… personally i would make all of my buttons movieclips with buttons in them that control the movieclips’ timelines. That way you can set your glow up on rollover, rollout, whatever. You can also control the timelines of your other button movieclips (i.e make other buttons fade out or do whatever on rollover or press/release whatever.)

i don’t feel like reading your code right now… but i did notice that you are using a single “=” symbol in your “if” statement. You need to use a comparison operator “==” when checking if something is equal to something and a single “=” when you are defining something as equal to something… make sense?

natronp, thanks for the clarification on “==”, I wondered about that, and that will really help. I keep meaning to go pickout a couple actionscript books and start studying up.

I agree with you about the setup, and have something similar. Basically I have a movie clip that has both a button and another movie clip (the glow animation). The problem I have is how to set it up to have both a ON RELEASE and a ON ROLLOUT without the ROLLOUT overriding the RELEASE. Does that make sense?

okay, i understand that.

make one movie clip. in that movie clip have four layers (can be more or you can have your animation in a movieclip). in the first layer have your animation. In the 2nd layer have your button. In the third have frame labels and in the fourth have actionscript.

set up your animation with markers (frame labels) so you can tell the clip what frame to go to with the button actionscript.

then to have a release animation that doesn’t get cancelled you have a separate animation for release and rollover (two framelabels on your timeline… if they’re in another mc within this mc then you’ll have to reference them in your AS accordingly).

then for your rollover… you’ll tell the mclip to gotoandplay the frames that contain your rollover animation. put this AS on your button

then for your release… you’ll declare a variable and give it a value. like; button1release = “true”; this way you’ll be able to tell if the button has been “released/hit”.

then on your rollout… you’ll have an “if” statement that checks first to see if the variable “button1release” equals “true” or not. if it is true have the AS do nothing. if it isn’t true have it go to and play the rollout animation.

you get it? so your code’ll look something like this:

on (release) {button1release="true";
	this.gotoAndPlay("releaseanim");}
on (rollOver) {this.gotoAndPlay("rolloveranim");}
on (rollOut) {
	if (button1release=="true") {stop();
	}else{this.gotoAndPlay("rolloutanim");}}
//this code should go in the last frame of your release animation to reset 
the variable
button1release="false";

this should work! let me know if you get stuck and good luck.