[AS3] List component change color of a button
Hello, i have the following problem:
I have a list component with the instance name "my_list", i have some items with some data, i have a variable called "data1" which is the value of the selected item and the instance name of some buttons, what im doing is a list woh change the color of buttons depending of which item in the list i selected. I attached the fla file for better understanding.
I have the following code who changes the color but the problem is when i change the color for a button it changes and with the next button but don't reset the previous button.
function changeHandler(event:Event):void {
var data1 = event.target.selectedItem.data;
var colorTransform:ColorTransform = this[String(data1)].transform.colorTransform;
colorTransform.color = 0xff0000;
this[String(data1)].transform.colorTransform = colorTransform;
addChild(this[String(data1)]);
this[String(data1)].alpha =.4;
}
my_list.addEventListener(Event.CHANGE, changeHandler);
|