Copy link to clipboard
Copied
I'm trying to create a Nav menu that has buttons that stays on a down state when clicked. I've seen on the forums that it'll be harder to do that on button so I made it a movie clip, however the action script on the movie clip only seem to work the first time. For Example if I click on "btn2" I can't go back to "btn1". Here's the code that I'm using
stop ();
Home.addEventListener (MouseEvent.CLICK,play11);
function play11(event:MouseEvent) :void{
gotoAndStop("Home");
}
Arrival.addEventListener (MouseEvent.CLICK,play12);
function play12(event:MouseEvent) :void{
gotoAndStop("Two");
}
Men.addEventListener (MouseEvent.CLICK,play13);
function play13(event:MouseEvent) :void{
gotoAndStop("Three");
}
Arrival and Home buttons seem to work fine but once I click on the "Men" button I can't click on Arrival anymore but I can however still click on home. Help?
if you want only the button that is clicked to be down and change when another is clicked here is a way:
If you have lots of buttons then I would do it differently.
...Home.addEventListener(MouseEvent.CLICK, buttonClicked);
Arrival.addEventListener(MouseEvent.CLICK, buttonClicked);
Men.addEventListener(MouseEvent.CLICK, buttonClicked);
function buttonClicked(event: MouseEvent): void {
trace(event.target.name);
Arrival.gotoAndStop(1);
Men.gotoAndStop(1);
Home.gotoAndStop(1);
if(eve
Copy link to clipboard
Copied
So you want the buttons to stay on the down state when they have been clicked and no go to a not down state?
In this case you could do this. I have the buttons with 2 frames - frame 1 is considered up (grey) and frame 2 is considered down (red)
Home.addEventListener(MouseEvent.CLICK, buttonClicked);
Arrival.addEventListener(MouseEvent.CLICK, buttonClicked);
Men.addEventListener(MouseEvent.CLICK, buttonClicked);
function buttonClicked(event: MouseEvent): void {
trace(event.target.name);
if(event.target.name == "Home"){
gotoAndStop("Home");
Home.gotoAndStop(2);
} else if (event.target.name == "Arrival"){
gotoAndStop("Arrival");
Arrival.gotoAndStop(2);
}else if (event.target.name == "Men"){
gotoAndStop("Men");
Men.gotoAndStop(2);
}
}
Copy link to clipboard
Copied
if you want only the button that is clicked to be down and change when another is clicked here is a way:
If you have lots of buttons then I would do it differently.
Home.addEventListener(MouseEvent.CLICK, buttonClicked);
Arrival.addEventListener(MouseEvent.CLICK, buttonClicked);
Men.addEventListener(MouseEvent.CLICK, buttonClicked);
function buttonClicked(event: MouseEvent): void {
trace(event.target.name);
Arrival.gotoAndStop(1);
Men.gotoAndStop(1);
Home.gotoAndStop(1);
if(event.target.name == "Home"){
gotoAndStop("Home");
Home.gotoAndStop(2);
} else if (event.target.name == "Arrival"){
gotoAndStop("Arrival");
Arrival.gotoAndStop(2);
}else if (event.target.name == "Men"){
gotoAndStop("Men");
Men.gotoAndStop(2);
}
}
Copy link to clipboard
Copied
Thanks for your help! Your example number 2 is what I'm looking for but I'll have to test it out after I have dinner. Btw, is there by any chance a way to message you so I can bump you if I have any questions? And on the example that you gave were you using Buttons or Movie Clips?
Copy link to clipboard
Copied
Sure let me know what you need. You can message me.
But there are people who are way better than me here.
I am using movie clips
Copy link to clipboard
Copied
Most of the versions i've seen from the forums are too complicated but yours seem to be simple for a newbie like me to understand so I'd rather ask you anyway, I sent you a message! Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now