我想制作循环按钮组,并向它们添加一些事件,但匿名函数是相同的.我写了示例代码:
for(var i:int=0;i<5;i++)
{
var button:SimpleButton = new SimpleButton(...);
...
button.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void
{
trace(i);
});
}
...
Run Code Online (Sandbox Code Playgroud)
我想从点击按钮而不是4,4,4,4跟踪0,1,2,3 ..你知道我怎么能做到这一点?