Delegate version 1.0.1
Monday, 02 May 2005I’ve updated my Delegate class to version 1.0.1 to add compatibility for MTASC. There are no functional changes, so if you’re not using MTASC there’s no need to download the updated class file.
See Delegate class refined for more information about the Delegate class.
–Update–
The Delegate class is licensed under the MIT licence. This is about as liberal a license as I could find which allows you to do pretty much anything with this code. I wouldn’t have bothered at all except some people were wondering whether they could use the code in commercial projects. The answer under the MIT license is a definitive yes.








Just trying it our with F.A.M.E. Works like a
adampasz | Saturday, 14 May 2005 | 1:45 pmJust trying it our with F.A.M.E. Works like a charm. Thanks!
[...] The initBroadcaster() method is from my Object Prototypes and
MAB Blog » Blog Archive » Determining When A MC Is Initialized | Thursday, 21 July 2005 | 12:57 pm[...] The initBroadcaster() method is from my Object Prototypes and simple initialized the object that the method is applied on as a EventDispatcher. If you dont know anything about EventDispatcher or listeners, I suggest you learn about them; they are one of the most helpful things in AS, this tutorial should give you what you need to know about EventDispatcher if you haven’t used it already. So after initializing the box MC as a EventDispatcher I added a function listener to the “inited” event that will be broadcasted by the box once it is fully initialized. The function is executed in the scope of the box, because of this the ‘this’ variable equals the box MC, thus this.play() will cause the box MC to start playing. If you didn’t want that function to exact in the boxes scope you can use the Delegate class to execute a function is different scope (Flash 7.2 also comes with a Delegate class but Steve’s Delegate class that I linked to is better). If you want to learn more about Delegates and how to use them read this tutorial. You can get both the updated animation initialization and the textfield initialization files here. [...]
class Delegate extends Object { static function create(obj:Object,
Maurits van der Schee | Wednesday, 22 February 2006 | 12:59 pmclass Delegate extends Object
{
static function create(obj:Object, func:Function):Function
{
return function () { return(func.apply(obj, arguments)); };
}
}
Maurits: Umm... that's a very simple version of the Delegate
Steve | Wednesday, 22 February 2006 | 1:06 pmMaurits: Umm… that’s a very simple version of the Delegate class, though you’ve needlessly extended Object on a class that has only static methods.
However, it doesn’t serve the same purpose as my delegate class, which is designed to allow you to pass extra arguments to the delegated function and also pass a reference to the delegate itself to make it easy, for example, to remove delegated event handlers.
Please see Delegate class refined for more information.