View Single Post
Old 12-04-2007, 09:55   #3 (permalink)
cam
vague™
 
cam's Avatar
 
Join Date: Mar 2004
Location: Glasgow
Posts: 5,738
More as3.0 goodness

Quote:
Method closures

Event handling is simplified in ActionScript 3.0 thanks to method closures, which provide built-in event delegation. In ActionScript 2.0, a closure would not remember what object instance it was extracted from, leading to unexpected behavior when the closure was invoked. The mx.utils.Delegate class was a popular workaround; to use it, you would write code as follows:

Code:
myButton.addEventListener("click", Delegate.create(this, someMethod)); Delegate.create(this, someMethod)


This class is no longer needed because in ActionScript 3.0, a method closure will be generated when someMethod is referenced. The method closure will automatically remember its original object instance. Now, one can simply write:

Code:
myButton.addEventListener("click", someMethod);

about fucking time!

Adobe - Developer Center : ActionScript 3.0 overview
__________________
  Reply With Quote