View Full Version : checking buttons

06-19-2003, 02:30 PM

Ive got 15 buttons in a scene and want to have a way to check whether there have been at least one button selected and no more than 8 buttons selected. Is there a way of doing this?


06-19-2003, 03:28 PM

can the buttons be selected and then deselected again?

If so you could do something like this,

totalSelected = 0;
myButton.onPress = function() { // action in the same timeline as the button, where the button instance name is myButton
if (this.count % 2) { // count is an odd number, the button has been selected
totalSelected++; // add 1 to the count of selected buttons
} else { // count is an even number
totalSelected--; // the button was deseleted, reduce the count of selected buttons

you can add the same event for each button in the movie. then at the end you can check the value of totalSelected to see how many buttons are selected.

If the buttons can't be toggled on and off, you can just have each button do something like this,

myButton.onPress = function() {
if (!this.clicked) {
this.clicked = true; // stop the button being clicked on again

Hope this helps :)

06-20-2003, 08:06 AM

havent tried it yet, but it looks like it might be useful.

thanx, Ill let you know if it works