Button hit state array

Hi,

I have some buttons on my main stage, what I want to do is:

when the pointer rolls over them they change to red
when the pointer rolls away them they change to black
when a button is clicked it stays yellow until another is clicked (it must also stay yellow if it is currently ‘clicked’ and rolled over).

I have patched this together, I can get the button to stay yellow onpress, or change to red onrollover but not both.

The buttons on stage are named but1, but2, but3, but4 as in the array below.


buttons_array = ["but1", "but2", "but3", "but4"];
// buttons instance names
defaultColor = "0x660000";
// initial color for every button
activeColor = "0xFFFF00";
// color for the active button
overcolor = "0xFF00FF";

// over
overButton = function () {
this._parent[buttons_array*]._name = overbut
if (overbut == activebut) 
{var d = new Color(this);
d.setRGB(activeColor);
} else {
var d = new Color(this);
d.setRGB(overcolor);}};

// out
outButton = function () {
this._parent[buttons_array*]._name = outbut
if (outbut == activebut) {;
var d = new Color(this);
d.setRGB(activeColor);
} else {;
var d = new Color(this);
d.setRGB(defaultColor);
}};

// down
activeButton = function () {
this._parent[buttons_array*]._name = activebut
var a = new Color(this);
a.setRGB(activeColor);
};

//test button states
for (var i in buttons_array) {
this[buttons_array*].onRollOver = overButton;
}
for (var i in buttons_array) {
this[buttons_array*].onPress = activeButton;
}
for (var i in buttons_array) {
this[buttons_array*].onRollOut = outButton;
}
}
}
}
}