Skip to main content
niallb45353356
Participant
December 5, 2017
Answered

How to Create a Button with Multiple Clicks?

  • December 5, 2017
  • 1 reply
  • 527 views

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.

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    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

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    December 6, 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

    niallb45353356
    Participant
    December 6, 2017

    It worked great!

    Thank you so much.

    JoãoCésar17023019
    Community Expert
    Community Expert
    December 6, 2017

    Nice!

    You're welcome!