Skip to main content
New Participant
May 24, 2019
Answered

Ultra new to flash need help with buttons

  • May 24, 2019
  • 2 replies
  • 352 views

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?

This topic has been closed for replies.
Correct answer avid_body16B8

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);       

    }

}

2 replies

avid_body16B8
avid_body16B8Correct answer
Brainiac
May 24, 2019

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);       

    }

}

leinard98Author
New Participant
May 24, 2019

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?

leinard98Author
New Participant
May 24, 2019

Sure let me know what you need. You can message me.

But there are  people who are way better than me here.

Buttons nav.zip - Box

I am using movie clips


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

avid_body16B8
Brainiac
May 24, 2019

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);

    }

}