Why are inline closures so rarely used in ActionScript? They are very powerful and I think are quite readable. I almost never see anyone using them, so maybe I'm just looking at the wrong code. Google uses them in its sample Google Maps APIs for Flash, but I think this is the only place I've seen them.
I prefer them because you have access to local variables in the area that defines them, and you keep the logic in one method and do not get many functions for which you have to come up with a name.
Are there any tricks to using them? They work almost the same way as in C #.
Actually, I just discovered that AS3 supports them, and I'm very annoyed because I thought I read that they are deprecated in AS #. Therefore, I will return to their use!
private function showPanel(index:int):void {
_timer = new Timer(1000, 1);
_timer.addEventListener(TimerEvent.TIMER, function(event:Event):void
{
showPanel(index++);
});
Simon source
share