PDA

View Full Version : MouseEventDispatcher anyone?



tezzutezzu
October 19th, 2007, 07:01 AM
Hello,
I find myself a little bored by the fact that every time I want to add any sort of mouse interaction to a DisplayObject I have to add at least 4 rows of addEventListener and 4 functions for each different state (at least over, out, down, up) in the DisplayObject class.

Just to know, has anyone came up with a mouse event dispatcher class yet?

senocular
October 19th, 2007, 10:44 AM
In what sense? I would think what you're looking for you already have since you've been doing it many times already... or are you looking for more?

tezzutezzu
October 19th, 2007, 12:07 PM
I was wondering if there was a way to dispatch from an EventDispatcher associated with a DisplayObject just an event (change) and then from this event get which kind of interaction the object had (mouse over, mouse out, and so on...).

senocular
October 19th, 2007, 12:48 PM
You'd have to listen for each event. You could use one event handler for each, then check the event.type property. But to get events for each of those events, addEventListener would need to be used for each.

If you're doing a lot of button work with the same event handlers, you could always make a subclass that defines them in a generic manner and then subclass that class when you make new buttons so you wouldnt have to do that over again each time

tezzutezzu
October 19th, 2007, 01:38 PM
thx for the reply sen, i've to go now, i'll try to do it and then (probably) ask you again tomorrow :)
cheers!