Let's say that you have your three buttons on the stage and have given them the instance names `btn1`, `btn2`, and `btn3`. First you should assign the
same click handler to each button and this handler should record the order in which buttons are clicked. Once you have a set number of clicks recorded (i.e. 3) then you should process which buttons have been clicked and in which order then act appropriately.
You might do that with something
very roughly like the following (I don't have flash installed to test it, you see), which ought to provide a basic implementation of what you're looking for:
ActionScript Code:
/*
* These are the buttons that we wish to track the sequential
* clicks of.
*/
var buttons:Array = [btn1, btn2, btn3];
/*
* A text record of the buttons that have been clicked.
*/
var record:String = '';
/*
* The number of button clicks we wish to record beforing
* checking
*/
var recordLength:Number = 3;
/**
* Handle the clicks of the button.
*
* Maintains the record and checks to see what action should
* be performed if we have recorded enough.
*/
function clickhandler()
{
// Add this button's id (explained later) onto the end of the record
record = record + this.id;
if (record.length == recordLength)
{
/*
* Process which order the buttons were clicked in
*/
if (record == '123')
{
// User clicked button 1, 2 and then 3.
}
else if (record == '321')
{
// User clicked button 3, 2 and then 1.
}
else
{
// User clicked the buttons in some other order.
}
// Reset the record
record = '';
}
}
/*
* We want to do the following for each button
*/
for (var i = 0; i < buttons.length; i++)
{
/*
* The id property of each button will be used to form
* the parts of the record of clicks that correspond to the
* respective button being clicked.
*
* We're using Strings so that we can concatenate them easily.
*/
buttons[i].id = (i + 1).toString();
/*
* Assign the click handler
*/
buttons[i].onclick = clickhandler;
}
Hope that helps
