Change Color on mouse click
Hi Guys. I have followed Ned's code from another post, whereby if a text button is clicked, the color will change. The code is like
var clicked:Boolean = false;
var clicked2:Boolean = false;
btn1.addEventListener(MouseEvent.CLICK, btn1click);
function btn1click(event:MouseEvent):void {
clicked = true;
var newColorTransform:ColorTransform = btn1.transform.colorTransform;
if(clicked){
newColorTransform.color = 0xc97f22;
} else {
newColorTransform.color = 0x000000;
}
btn1.transform.colorTransform = newColorTransform;
gotoAndStop(5);
}
btn2.addEventListener(MouseEvent.CLICK, btn2click);
function btn2click(event:MouseEvent):void {
clicked2 = true;
var newColorTransform:ColorTransform = btn2.transform.colorTransform;
if(clicked2){
newColorTransform.color = 0xc97f22;
} else {
newColorTransform.color = 0x000000;
}
btn2.transform.colorTransform = newColorTransform;
gotoAndStop(6);
}
Now if I click on the first button, it changes color and stays like that, which is perfect. If I click on btn2, this changes color and stays like it. The problem is that if btn2 is pressed, it should change color and stay like it (as it is doing), but btn1 should return back to its normal color (black). I am not sure how to achieve this.
Any advise appreciated
Cheers