We’re working on a rush project and to save time are using our designer’s mock-up as a starting point (we usually re-create it from the ground up). One issue is that he occasionally uses plain old Flash buttons instead of Button components because you can’t instance skin a button on stage.
In order to work with these buttons we usually use a simple onRelease handler that calls a function on _parent, as in the following example.
buttonOne.onRelease = function() {
this._parent.buttonOneClick();
}
function buttonOneClick() {
trace("one");
}
But after a little experimenting we found that the new mx.utils.Delegate class included with the Flash MX 2004 7.2 Updater can be used with plain old Flash buttons too, not just components. The following example is a little cleaner.
import mx.utils.Delegate;
buttonTwo.onRelease = Delegate.create(this, buttonTwoClick);
function buttonTwoClick() {
trace("two");
}