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

How to Create a Button with Multiple Clicks?

New Here ,
Dec 05, 2017 Dec 05, 2017

Hello

I've recently been learning how to use buttons in flash. I understand how to make a symbol visible with a button.

But I was wondering how I could create a single button which could make one symbol visible after another with repeated clicks.

For example, 1 click means a box appears, 2 clicks means another box appears and so on, with a maximum of say 30.

I can't find information about how to do this anywhere. So any help would be appreciated.

455
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

Community Expert , Dec 05, 2017 Dec 05, 2017

You can do this:

- Create a button called show.

- Create a container Movie Clip called boxes.

- Add as many Movie Clips as you want to this boxes Movie Clip.

- Set all children Movie Clips of this container to be invisible.

- Add this code to the main timeline:

import flash.events.MouseEvent;

var count:uint = 0;

show.addEventListener(MouseEvent.CLICK, clickHandler);

function clickHandler(e:MouseEvent):void

{

    if (count < boxes.numChildren)

    {

        boxes.getChildAt(count).visible = true;

        count

...
Translate
Community Expert ,
Dec 05, 2017 Dec 05, 2017

You can do this:

- Create a button called show.

- Create a container Movie Clip called boxes.

- Add as many Movie Clips as you want to this boxes Movie Clip.

- Set all children Movie Clips of this container to be invisible.

- Add this code to the main timeline:

import flash.events.MouseEvent;

var count:uint = 0;

show.addEventListener(MouseEvent.CLICK, clickHandler);

function clickHandler(e:MouseEvent):void

{

    if (count < boxes.numChildren)

    {

        boxes.getChildAt(count).visible = true;

        count++;

    }  

}

Done.

FLA/SWF download: here.

I hope it helps.

Regards,

JC

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 ,
Dec 06, 2017 Dec 06, 2017

It worked great!

Thank you so much.

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
Community Expert ,
Dec 06, 2017 Dec 06, 2017
LATEST

Nice!

You're welcome!

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