Event dispatcher, the next morning

Ok, I have to post a bit of a retraction. While EventDispatcher is still a big improvement over previous event models, it’s not quite as cool as I thought it was at 3am last night. Nothing ever looks quite as hot the morning after, does it?

The ability to subscribe functions or methods to events is made vastly less useful than I excitedly thought last night by the fact that the function will, of course, be executed within the scope of the object dispatching the event (duh). This means that really, this approach is only about as useful as a callback event handler (the functionality is virtually identical) – its occasionally handy for quick’n’dirty prototyping, but usually not good form.

Ahh… the murky clarity of 3am experimentation. Oh well, stay tuned, I hope to build out an extended version of the eventDispatcher that includes some nifty new tricks.

Grant Skinner

The "g" in gskinner. Also the "skinner".

@gskinner

7 Comments

  1. check your previous blog entry on this subject. I posted what I wrote a while back. its the eventdispatcher, plus it allows you to define the object and method you wish to call if you want. it also lets you pass args (despite being less OOP in this manner)

  2. Have you taken a look at Mach-II which morphed as an ‘OO’ framework from Fusebox? I do realize at this point most samples etc on written for CFMX.

  3. ahh, morning Afters..:p

  4. Auto Format your logic!

    I just discovered a pretty serious bug in Auto-Format: If you run the following code, you’ll get “true 2”: function test() { if (true) { if (true) { trace(“true 2”); } else // false 2 { trace(“false 2”); } }…

  5. I think it’s great because you can call public methods on the dispatcher from another object without explicitly calling the object. Does it break OO if you do this from a view that knows nothing of a model? Even if it does I think this functionality is great. AsBroadcaster couldn’t do it.

  6. Choosing a Flash Event Engine That’s Right For You

    What event engine is right for you? Read on to find out! Careful, she’s a long one……

  7. How about using delegates?

    I assume the use of delegates so I simply extended eventDispatcher to take two forms of addlistener, one with a delegate and the original form uses arguments.callee and builds a delegate on the fly. – most times, the target object is the same one adding a listener.

Leave a Reply

Your email address will not be published. Required fields are marked *