Copy link to clipboard
Copied
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.
1 Correct answer
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
It worked great!
Thank you so much.
Copy link to clipboard
Copied
Nice!
You're welcome!

