我正在尝试创建一个显示您按下的按钮名称的系统。按钮名称被放入一个数组中,但是它只识别最后一个输入到数组中的项目。帮助将不胜感激。
var items:Array = [a, b, c]; //The name of each button
for each(var index in items)
{
index.addEventListener(MouseEvent.CLICK, mouseClickHandler);
}
function mouseClickHandler(event:MouseEvent):void
{
trace(index.name); //Should display the name of any of the buttons clicked.
}