Hi
Basically I have 16 buttons which I want to change colour when turned on and off kinda thing using colourTransform. I have achieved this by using 16 event listners and 16 functions but know there must be a better approach. I kinda got it working with one function using e.currentTarget but cant figure out to store the on/off state of each button to send to the one function whilst using e.currentTarget. E.G. Turn one button on and will have to click another twice to turn it on.
How could this be solved. Hope this makes sense. Thx.
ActionScript Code:
b1.addEventListener(MouseEvent.CLICK, onPattern, false, 0,
true);
b2.addEventListener(MouseEvent.CLICK, onPattern, false, 0,
true);
function onPattern(e:MouseEvent):void{
on1 = on1+1
if(on1 >= 2){
on1 = 0
colorInfo1.greenOffset = 0;
colorInfo1.blueOffset = 0;
colorInfo1.redOffset = 0;
e.currentTarget.transform.colorTransform = colorInfo1;
}
if(on1 == 1){
colorInfo1.greenOffset = 20;
colorInfo1.blueOffset = -100;
colorInfo1.redOffset = -65;
e.currentTarget.transform.colorTransform = colorInfo1;
}
}