Actually, there aren't many Decorators in AS3 that I can find.

Additionally, EventDispatcher is built-in.  MovieClip actually extends 
EventDispatcher, so no need for all the mixin stuff.

----- Original Message ----- 
From: "Javier Tello" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com>
Sent: Sunday, November 13, 2005 12:33 PM
Subject: Re: [Flashcoders] dispatching events from a class


Thanks Jester, I know, it was a discussion about using or not the
"prototype" keyword, and if actionscript will support it in future
versions. But like you say, it is still being used also in as3. I will
try it.

Regards,

Javier.

El 13/11/2005, a las 17:44, JesterXL escribió:

> EventDispatcher uses the Decorator pattern, and technically adds
> methods to
> whatever you pass in.  Since you are running it in the constructor,
> you are
> adding methods to the instance.  You are better off adding them to the
> class' prototype, so that only 4 methods are added to your class
> instead of
> 4 per instance.  Everytime you make a new instance of your class, 4 new
> methods are added to the instance, meaning 4 more functions in RAM vs.
> just
> 4 on the prototype, and all instances, 1 or million, all pointing to
> just
> those same 4 in memory.
>
> You use a static initializer to do this, it runs once, during the class
> registration phase.
>
> class YourClass
> {
>     public var addEventListener:Function;
>     public var removeEventListener:Function;
>     private var dispatchEvent:Function;
>
>     private static var mixin:Void =
> EventDispatcher.initialize(YourClass.prototype);
> }
>
>> From then on, you can use the functions as you have; this is just way
>> more
> efficient for RAM usage.
>
> To your credit, a lot of base classes such as UIComponent, in both
> Flex,
> Flash, and Flex 2 & ActionSript 3 utilize events "from yourself", so
> the:
>
> addEventListener("mouseDown", this);
>
> Will be more common.
>
> ----- Original Message -----
> From: "Javier Tello" <[EMAIL PROTECTED]>
> To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com>
> Sent: Sunday, November 13, 2005 10:25 AM
> Subject: Re: [Flashcoders] dispatching events from a class
>
>
> Yes ok Muzak, but  for example, it's the way the Tween class were
> implemented. It is like an onEnterFrame build in event, just to get
> less code lines in the main movie.
>
> I do not remember who, but someone discuss this issue, relating how to
> implement the EventDispatcher class, and explaining to do it in the
> constructor.
>
>
> El 13/11/2005, a las 15:15, Muzak escribió:
>
>>  Delegate.create(this, this.eventHandler));
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders 

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to