EventDispatcher is part of the Flash Player, not the Flex framework. This is how the player works. C#'s event delegate model is elegant, but that's not how Flash is set up. They elected to follow the w3c dom level 3 event specification (http://www.w3.org/TR/2001/WD-DOM-Level-3-Events-20010410/DOM3-Events.html), which lays out how events are subscribed to and dispatched.
What you have to realise, and Ted touched on, is that the Flash Player is completely different environment from C# or Java. The focus is on compactness, and sometimes there are design compromises. The compromise here is some unused functionality versus more code in the player. However, I don't believe that there are any detrimental effects.
I
sad that I can describe better solution if you will be open for discussion.
I
don't think anyone is short on solutions. There are plenty of ways to
implement an event model, but I'm sure yours is far superior to all of
them.
My objection was that you said "it's slow", but then didn't provide any
evidence or explain further in what way it is slow. There is little
value in a "better solution" for a non-problem.
Um.. Are you keeping some kind of score? If so, I'm not sure what of.
I mean that you can't press ctrl+space and see events (in outline, like properties and functions) . Sure you can use Flex "Metadata" keywords do describe events dispatched by class and editor will understand them but it's not a solution it's a kind of crutches cause in AS3 we don't have real metadata. (like metadata in C# or annotations in Java)
I agree. It's a limitation. Partly of the language, but partly of the currently available editors. I keep constants for most of my events on the object that is dispatching it. That lets me do:
myObj.addEventListener(myObj.EVENT_NAME, onEventName);
and I get hinted on the event name in my editor. That is exactly the same experience as in C#:
myObj.EventName += new EventNameHandler( OnEventName );
where I get hinted on EventName.
I don't know how either of the languages would deal with bubbled events, and I believe that Adobe elected to store event type constants on the Event class instead of the event source because it is at least consistent. Does your better solution cater for that?
Peter
TREE STRUCTURE. So can you explain me why Timer extends EventDispatcher. Can you imagine TREE STRUCTURE of
> Timers???
You lost me. Timer uses EventDispatcher so that it can dispatch timer events. There is no implication of any structure. There are certainly features of EventDispatcher that are not used by Timer, but there is no cost, and I'd much prefer inheritance over a mixin. Adding dispatcher capabilities via composition would be more costly for both memory and performance.If you see only 2 solutions: inheritance and mixin it's your problem. There are better solutions. EventDispatcher has spare functionality and it's bad design.
>.1. It's based on string identifiers. Because of this
> a. It's slow
Do you have any evidence to back that up? Strings are convenient for a number of reasons. In particular for debugging.I sad that I can describe better solution if you will be open for discussion.
> b. You don't know for real types of events that object can dispatch.
I agree with that. In my own code, I keep constants on the class that does the dispatching, rather than event class. However, it isn't always so straightforward - for example where events can bubble, the events that an object can dispatch are based on what children are added at runtime.1-0
> c. You can't use code-inside in editor for access events.
I don't know what you mean here...I mean that you can't press ctrl+space and see events (in outline, like properties and functions) . Sure you can use Flex "Metadata" keywords do describe events dispatched by class and editor will understand them but it's not a solution it's a kind of crutches cause in AS3 we don't have real metadata. (like metadata in C# or annotations in Java)
Max
Peter
On 4/6/06, Maxym < [EMAIL PROTECTED]> wrote:
Yeah, I can.
DOM Specification: The first goal is the design of an event system which allows registration of event listeners and describes event flow through a tree structure.
TREE STRUCTURE. So can you explain me why Timer extends EventDispatcher. Can you imagine TREE STRUCTURE of Timers???
For real there are many bad things in this event model:
1. It's based on string identifiers. Because of this
a. It's slow
b. You don't know for real types of events that object can dispatch.
c. You can't use code-inside in editor for access events.
2. EventDispatcher and IEventDispatcher have too much extra functionality that will be used only for visual objects.
3. If you want to dispatch events and you can't extend EventDispatcher you have to duplicate (do you know some AOP concepts) it's logic (at least one time) and implement IEventDispatcher.
4. I can say more but I'm tired of typing…
From: [email protected] [mailto: [email protected]] On Behalf Of Darron J. Schall
Sent: Thursday, April 06, 2006 5:46 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Question to Adobe about Flex Framework 1.5 Code Quality
maxym.hryniv wrote:
> Looking at Flex 2 framework event model, and Flex 2 Framework UML
> (Flex 2 api visual reference by Rocket Boots) I don't believe that
> Flex 2 is better.
Can you be more specific? The event model is fundamentally part of the
player is an based on the DOM Level 3 Events specification [1].
-d
[1] http://www.w3.org/TR/DOM-Level-3-Events/
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
· Visit your group " flexcoders" on the web.
· To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
· Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development Computer software development Software design and development Macromedia flex Software development best practice
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

