On 1/29/07, Steven Sacks | BLITZ <[EMAIL PROTECTED]> wrote:
If you want to discuss best practice for what you're doing, I'd be happy to offer ideas later today when I have more time.
I'm a little confused as to why the original poster would want to dynamically add or remove functionality to/from an object at runtime. That sounds a bit unstable--code that works perfectly fine when the functionality is added would break when the functionality is removed. Perhaps it is better to add a flag (like the "enabled" property of movie clips and buttons) and disable certain functionality when it is false (or true or whatever).
Other people might be able to chime in here on the best application of Decorator in Actionscript.
Personally, I find one of the best uses to be in place of "mixing in" (i.e., copying functions from the prototype of one class to an unrelated class). In essence, it's a way to get around the "every class can have only one parent" problem. For example, if I have an IEventDispatcher interface that's implemented by an EventDispatcher class that's descended from Object, then I can't have a component that extends EventDispatcher because components (in AS2) must extend MovieClip. The solution: make a DispatcherClip class that extends MovieClip and implements IEventDispatcher by keeping a hidden EventDispatcher object and wrapping/decorating its public functions. -- T. Michael Keesey Director of Technology Exopolis, Inc. 2894 Rowena Avenue Ste. B Los Angeles, California 90039 _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

