Creating anonymous functions in loop with not the same arguments
- by onio9
Hello!
I want to make in loop set of buttons, and add to them some events, but anonymous functions is the same. I write example code:
for(var i:int=0;i<5;i++)
{
var button:SimpleButton = new SimpleButton(...);
...
button.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void
{
trace(i);
});
}
...
And I want to trace 1,2,3.. from click buttons instead of 4,4,4,4 ..
Do you know how can I make this ?