Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Ultra new to flash need help with buttons

New Here ,
May 24, 2019 May 24, 2019

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?

279
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 24, 2019 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(eve

...
Translate
LEGEND ,
May 24, 2019 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);

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 24, 2019 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);       

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2019 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 24, 2019 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2019 May 24, 2019
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines