Annonymous functions accessing local variables [ActionScript - Flex 3.5]
- by Ali
Hi All,
I am having a situation with my actionscript/flex front end.
for each (var sym:String in ["A","B","C"]) {
const handler = function (data:Object):void { Alert.show(sym); }
asyncCallback(handler);
}
I am expecting to have 3 Alert windows containing A, B and C. But the actual result is 3 alert windows all showing C !
I appreciate your comments.
-A