----- Original Message ----- 
From: "Dan" <[email protected]>
To: <[email protected]>
Sent: Monday, January 12, 2009 9:57 PM
Subject: [flexcoders] Re: How to create universal event handler?


>
>> Nope, I meant the process described here:
>>
> http://livedocs.adobe.com/flex/3/html/help.html?content=createevents_3.html
>
> Howard, I read the docs before posting to the group but it does not
> provide the answer for what I am looking.
>
>> But I think Manish's answer is the easier approach.
>
> Neither does Manish's answer.
>
> I do not know the type of event that I am trying to catch. All I know
> is that it inherits MyEvent.
> I cannot write addEventListener("foo", commonHandler), since I do not
> know what string developer will use for event type; it can be "foo",
> "baz" or "chooseyourown".
> I am writing a library that I would like other developers to extend. I
> would like to handle event that some other developer wrote extending
> my base event. The fact that he extended my base event class should be
> a criteria I should use to handle the event.

I can't help but think that you're getting mixed up between the difference 
in concept between the class of an event and the event name.

Event handlers respond to specific event instances by name and not class. 
You're trying to respond to all events descended from your event. Someone 
has already responded with the suggestion that you should have a single 
event name and differentiate between uses of that event by including an 
event payload (a variable inside a custom event) to differentiate between 
them.

Earlier I expressed the view that you are really building a controller 
inside the event handler and it's probably not a good idea at all.

Paul 

Reply via email to