Advantages of the new mx.utils.Delegate class over EventProxy classes

The Flash 7.2 updater includes a new utility class, mx.utils.Delegate. This very useful class is used to redirect event handlers so you can subscribe to one event and have the component call a method by a different name in your class. For example, if you have a save button and a cancel button, the Delegate class makes it easy to call saveClick and cancelClick in your class instead of just a single click method and having to determine which button was clicked.

Many of us already had custom classes that accomplished the same results, often called EventProxy. However, it is worthwhile to replace usage of those classes with Delegate because Delegate has a major advantage: compile time checking.

In most previous iterations of EventProxy, including my own, the proxy was created by specifying the method to call as a string. However, the Delegate asks for the method to be specified as a reference. Therefore the Delegate instantiation involves compile-time checking and can help reduce errors.

For more information on mx.utils.Delgate, read Mike Chamber’s “Proxying Events with the mx.utils.Delegate Class” article on DevNet.

If you don’t already have it, download the free Flash 7.2 updater.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>