0 Replies Latest reply on May 7, 2008 9:51 AM by BeniRose

    Event Listeners VS Event Functions

    BeniRose
      I'm working on a new project at work where there's lots of custom objects with lots and lots of event listeners. I keep finding myself saying, "why didn't they just use the built in objects with built in event handling?". However, from what I can see it seems like AS3 leans heavily towards using Event Listeners as opposed to putting event responsibility on the object itself (E.G. XML.onload). Is there an advantage to this (other than making it more Java like?) I've always favoured keeping the responsibility on the object itself because it seems like one less object to keep track of and also makes things feel more self contained. If I have 10 objects that fire 10 different events, I have to create 10 different event handlers (or 10 different case statements within the same event handler), whereas with self event handling, I just code in the event function.

      Anyways, I wanted to open discussion to which method of event handling you prefer and why, and also what you believe the advantages to this. I was searching google for previous discussions on this but I couldn't seem to find anything, so I thought I'd get the ball rolling! Looking forward to reading these, try not to be too elitist in your posts!!