1 Reply Latest reply on Sep 23, 2007 3:14 AM by thx1199

    event dispatch issues (ActionScript 3)

    Chris Ivey
      First off, PLEASE don't tell me that this is the "intended behaviour"

      I see from the AS3 documentation that events dispatched from the stage don't get propagated beyond the target phase. The curious thing is that this seems to hold true for static classes and document classes as well.

      I am writing a static class for sound management that has to be portable between several different frameworks. This means that it can't rely on method calls or singleton objects to pass events to other objects.

      I found that events dispatched from inside the class are only ever "heard" inside that class. They never propagate out. Since all of our frameworks use a standard base class, I thought that I could get around this by creating one method in that base class, passing objects through to it, and then having events dispatched with the object I pass as the event target. However, the base class is instantiated as a document class, and it exhibits the same symptom: the method gets called, and the event IS dispatched, but nothing outside the document class can hear it, on either the capture or the bubbling phase. If I pass in a null object, then the document class receives the event. If I pass in an object that extends EventDispatcher, then that object gets it.

      What gives? Are document classes considered part of the stage object? How can I work around this without dinking around with dynamically created dispatchers or silliness like that? Is there a good, solid workaround I can use? I don't need to pass out a lot of events, but the ones I need are important. I fire one when the sounds are loaded, and another when the sound completes.

      Here's a curious thing - I have the static sound manager class create an extended Sound object. It fires the complete event. The class that created the sound object can here the event, but nothing else can. And again, if I have the static class dispatch a new event, only the class that dispatched it can receive the event.

      I have messed around with multiple listeners set to receive events in both the bubbling and capture phases to no avail.

      And yes, I have had no problem using EventDispatcher elsewhere in our applications.

      Any help or ideas would be appreciated.