March 17, 2004
The V2 component architecture relies heavily on the "mix-in" design pattern. "Mix-ins" are a way to add functionality to ClassB from ClassA without the requirement of ClassB having to be a subclass (an inheritance relationship) of ClassA. This is perfect for ActionScript because of the dynamic nature of the language. You can basically add functionality to a class at any time without throwing a compiler error (which I guess can be good or bad depending on how you look at it :). Probably the most well known mix-in is EventDispatcher, which mixes methods for adding/removing listeners and dispatching events into other classes. There have been several good write ups on using and extending EventDispatcher including those by Ahmet, Grant (gDispatcher) and even me:)
However, there are a lot of places where methods are mixed into classes that can make it difficult for a developer to track down where certain functionality is located. For example, do you ever wonder how you can call "createClassObject" from any frame in your movie? Well, that method is actually mixed into MovieClip.prototype from the V2 architecture. There are also several methods mixed into Array.prototype and XMLNode.prototype.
Anyway, I put together a quick list of some of the mixed in methods I found in V2 (not exhaustive I'm sure). Maybe it'll come in handy sometime
In this doc, I've listed broken down the classes that get methods mixed into them, the method that's mixed in, the class implementing the method, the class actually doing the mixing in, and the class that initializes this mix in process.Posted by philter at March 17, 2004 09:03 PM