PDA

View Full Version : Active state for flash navigation buttons?


flashbe
10-24-2008, 12:05 AM
I have created a flash menu and inerted it in an html page. everything works except the active state. I created the buttons as movie clips. Here's the actionscript I used:

about_mc.onRollOver = function () {
about_mc.gotoAndPlay("_over");
}

about_mc.onRollOut = function () {
about_mc.gotoAndPlay("_out");
}


videos_mc.onRollOver = function () {
videos_mc.gotoAndPlay("_over");
}

videos_mc.onRollOut = function () {
videos_mc.gotoAndPlay("_out");
}


photos_mc.onRollOver = function () {
photos_mc.gotoAndPlay("_over");
}

photos_mc.onRollOut = function () {
photos_mc.gotoAndPlay("_out");
}



about_mc.onRelease = function () {
getURL("about.html");
}

videos_mc.onRelease = function () {
getURL("videos.html");
}

photos_mc.onRelease = function () {
getURL("photos.html");
}

I have created keyframes as _over, _down and _out, but for some reason the "active" state doesn't work. Any suggestions much appreciated!

atomic
10-24-2008, 02:58 AM
What do you mean by active state?

runtime
10-27-2008, 04:26 PM
I have created keyframes as _over, _down and _out, but for some reason the "active" state doesn't work. Any suggestions much appreciated!

He means he wants something to stay active when a user clicks on a nav button. like a highlight or a tab.

First of all, DO NOT USE flash's built in keyframe state feature...it will not work in this case and in fact will ruin what I'm about to show you.

Here is what you want to do.

1. create a variable for the current state
var activeBtn:Number = 0;

2. create different states for your button and then check if the button that has been pressed is indeed the activeBtn

about_mc.onPress = function() {
trace("about PRESS");
_level0.activeBtn = 1; //sets the var to 1, or basically saying that this is the active button.
this.gotoAndPlay(2) // don't use over or out, in fact remove the label names

}

about_mc.onRollOver = function() {
trace("about ROLLOVER");
this.gotoAndStop(3); // again use the frame number that is appropriate
}

about_mc.onRollOut = function() {
trace("about ROLLOUT");
trace("activeBtn -->"+_level0.activeBtn);
if (_level0.activeBtn !=1) { // if this button does NOT equal the active button, which it DOES, so this statement is true.
trace("---->>> got in");
this.gotoAndStop(1); // again use appropriate frame #
}
}

You will need to repeat this for each button and have each button change the activeBtn var to "2" and "3".... and then your conditional statement will change to "!=2", and "!=3" respectively.

Hopefully this is somewhat clear.

atomic
10-27-2008, 04:28 PM
http://www.actionscripts.org/showMovie.php?id=564